Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
vbcc [2024/08/20 19:53] – [The startup file] pulkomandyvbcc [2024/08/27 17:20] (current) – [The configuration file] Fix typos, add missing asv pulkomandy
Line 51: Line 51:
       * startup.o       * startup.o
       * libvc.a       * libvc.a
 +    * include/
 +      * ctype.h
 +      * stdlib.h
 +      * string.h
     * vlink.cmd     * vlink.cmd
  
Line 62: Line 66:
 -ccv=vbccunsp -I"$VBCC"/targets/unsp-vsmile/include %s -o= %s %s -O=%ld -ccv=vbccunsp -I"$VBCC"/targets/unsp-vsmile/include %s -o= %s %s -O=%ld
 -as=vasmunsp_std -quiet -ile -Fvobj %s -o %s -as=vasmunsp_std -quiet -ile -Fvobj %s -o %s
 +-asv=vasmunsp_std -ile -Fvobj %s -o %s
 -rm=rm %s -rm=rm %s
 -rmv=rm %s -rmv=rm %s
--ld=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vmsile/lib "$VBCC"/targets/unsp-vsmile/lib/startup.o %s %s -o %s -lvc +-ld=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vsmile/lib "$VBCC"/targets/unsp-vsmile/lib/startup.o %s %s -o %s -lvc 
--ldv=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vmsile/lib "$VBCC"/targets/unsp-vsmile/lib/startup.o %s %s -o %s -lvc -Mmapfile +-ldv=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vsmile/lib "$VBCC"/targets/unsp-vsmile/lib/startup.o %s %s -o %s -lvc -Mmapfile 
--l2=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vmsile/lib %s %s -o %s +-l2=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vsmile/lib %s %s -o %s 
--l2v=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vmsile/lib %s %s -o %s -Mmapfile+-l2v=vlink -ole -b rawbin1 -Cvbcc -T"$VBCC"/targets/unsp-vsmile/vlink.cmd -L"$VBCC"/targets/unsp-vsmile/lib %s %s -o %s -Mmapfile
 </code> </code>
  
Line 263: Line 268:
 vbcc does not come with an open source C library. A full one from other sources could be compiled, but we don't need a complete C library. vbcc does not come with an open source C library. A full one from other sources could be compiled, but we don't need a complete C library.
  
-So here is a very minimal one with enough support to run the compiler.+So here is a very minimal one with enough support to run the compiler and to run Contiki, which has minimal needs from the C library (just a few string functions).
  
 <code c> <code c>
Line 334: Line 339:
 vc +vsmile -nostdlib -O3 -c libc.c vc +vsmile -nostdlib -O3 -c libc.c
 ar cru libvc.a libc.o ar cru libvc.a libc.o
 +</code>
 +
 +We also need some include files. ctype.h and stdlib.h can be empty, but they are used by Contiki so they must exist.
 +
 +string.h has some basic functions declarations and type definitions:
 +
 +<code c>
 +#ifndef __STRING_H
 +#define __STRING_H 1
 +
 +/*
 +  Adapt according to stddef.h.
 +*/
 +#ifndef __SIZE_T
 +#define __SIZE_T 1
 +typedef unsigned int size_t;
 +#endif
 +
 +#undef NULL
 +#define NULL ((void *)0)
 +
 +/*
 +  Many of these functions should perhaps be implemented as
 +  inline-assembly or assembly-functions.
 +
 +  Most suitable are:
 +  - memcpy
 +  - strcpy
 +  - strlen
 +  - strcmp
 +  - strcat
 +*/
 +void *memcpy(void *,const void *,size_t n);
 +void *memmove(void *,const void *,size_t);
 +void *memset(void *,int,size_t);
 +int memcmp(const void *,const void *,size_t);
 +void *memchr(const void *,int,size_t);
 +char *strcat(char *,const char *);
 +char *strncat(char *,const char *,size_t);
 +char *strchr(const char *,int);
 +size_t strcspn(const char *,const char *);
 +char *strpbrk(const char *,const char *);
 +char *strrchr(const char *,int);
 +size_t strspn(const char *,const char *);
 +char *strstr(const char *,const char *);
 +char *strtok(char *,const char *);
 +char *strerror(int);
 +size_t strlen(const char *);
 +char *strcpy(char *,const char *);
 +char *strncpy(char *,const char *,size_t);
 +int strcmp(const char *,const char *);
 +int strncmp(const char *,const char *,size_t);
 +int strcoll(const char *,const char *);
 +size_t strxfrm(char *,const char *,size_t);
 +
 +#endif
 </code> </code>
 ====== Running the compiler ====== ====== Running the compiler ======
 +
 +Note: make sure you have set the VBCC environment variable as explained earlier, otherwise the compiler will not find the target configuration and will complain and not compile anything.
  
 To compile a .c file into a .o file: To compile a .c file into a .o file:
vbcc.1724183601.txt.gz · Last modified: 2024/08/20 19:53 by pulkomandy
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0