DMCP_SDK Hello World

This is where developers can exchange ideas and ask questions relevant to the DM42 firmware.

Please note that Swiss Micros staff are unable to provide answers here as a general rule. This is intended as a community-driven forum.
Michael
Site Admin
Posts: 261
Joined: Wed Apr 05, 2017 11:31 pm

DMCP_SDK Hello World

Post by Michael »

Here is a 'Hello World!' demo application
https://github.com/swissmicros/DMCP_SDK

A simple RPN calculator demo application will follow.
Logan
Posts: 34
Joined: Sun Jul 09, 2017 1:03 am

Re: DMCP_SDK Hello World

Post by Logan »

Exciting!
DM42 SN:00210
DM41X SN:00014
Vitasam

Re: DMCP_SDK Hello World

Post by Vitasam »

Build with -pedantic-error compiler option:

Code: Select all

DMCP_SDK$ make
arm-none-eabi-gcc -c -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -Idmcp -Isrc   -Wall -fdata-sections -ffunction-sections -Wno-misleading-indentation -pedantic-errors -O2 -g  -MD -MP -MF .dep/pgm_syscalls.o.d -Wa,-a,-ad,-alms=build/pgm_syscalls.lst dmcp/sys/pgm_syscalls.c -o build/pgm_syscalls.o
In file included from dmcp/dmcp.h:41:0,
                 from dmcp/sys/pgm_syscalls.c:44:
dmcp/ff_ifc.h:56:23: error: ISO C90 does not support 'long long' [-Wlong-long]
 typedef unsigned long long QWORD;
                       ^
In file included from dmcp/sys/pgm_syscalls.c:44:0:
dmcp/dmcp.h:44:1: error: C++ style comments are not allowed in ISO C90
 // ----------------------------------
 ^
dmcp/dmcp.h:44:1: error: (this will be reported only once per input file)
dmcp/dmcp.h:240:29: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printAt(ds, ln, ...)  do { lcd_setLine(ds, ln); lcd_print(ds, __VA_ARGS__); } while(0)
                             ^
dmcp/dmcp.h:241:24: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printR(ds, ...)       do { ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
                        ^
dmcp/dmcp.h:242:30: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printRAt(ds, ln, ...) do { lcd_setLine(ds, ln); ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
                              ^
dmcp/dmcp.h:474:14: error: redefinition of typedef 'void_fn_t' [-Wpedantic]
 typedef void void_fn_t();
              ^
dmcp/dmcp.h:285:14: note: previous declaration of 'void_fn_t' was here
 typedef void void_fn_t();
              ^
dmcp/sys/pgm_syscalls.c:52:25: error: C++ style comments are not allowed in ISO C90
  PROG_INFO_MAGIC,       // uint32_t pgm_magic;
                         ^
dmcp/sys/pgm_syscalls.c:52:25: error: (this will be reported only once per input file)
dmcp/sys/pgm_syscalls.c:54:2: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  (void*)Program_Entry,  // void * pgm_entry;
  ^
cc1: warning: unrecognized command line option "-Wno-misleading-indentation"
Makefile:131: recipe for target 'build/pgm_syscalls.o' failed
make: *** [build/pgm_syscalls.o] Error 1
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: DMCP_SDK Hello World

Post by ijabbott »

Vitasam wrote:
Thu Jun 14, 2018 9:43 pm
Build with -pedantic-error compiler option:

Code: Select all

DMCP_SDK$ make
arm-none-eabi-gcc -c -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -Idmcp -Isrc   -Wall -fdata-sections -ffunction-sections -Wno-misleading-indentation -pedantic-errors -O2 -g  -MD -MP -MF .dep/pgm_syscalls.o.d -Wa,-a,-ad,-alms=build/pgm_syscalls.lst dmcp/sys/pgm_syscalls.c -o build/pgm_syscalls.o
In file included from dmcp/dmcp.h:41:0,
                 from dmcp/sys/pgm_syscalls.c:44:
dmcp/ff_ifc.h:56:23: error: ISO C90 does not support 'long long' [-Wlong-long]
 typedef unsigned long long QWORD;
                       ^
In file included from dmcp/sys/pgm_syscalls.c:44:0:
dmcp/dmcp.h:44:1: error: C++ style comments are not allowed in ISO C90
 // ----------------------------------
 ^
dmcp/dmcp.h:44:1: error: (this will be reported only once per input file)
dmcp/dmcp.h:240:29: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printAt(ds, ln, ...)  do { lcd_setLine(ds, ln); lcd_print(ds, __VA_ARGS__); } while(0)
                             ^
dmcp/dmcp.h:241:24: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printR(ds, ...)       do { ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
                        ^
dmcp/dmcp.h:242:30: error: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
 #define lcd_printRAt(ds, ln, ...) do { lcd_setLine(ds, ln); ds->inv=1; lcd_print(ds, __VA_ARGS__); ds->inv=0; } while(0)
                              ^
dmcp/dmcp.h:474:14: error: redefinition of typedef 'void_fn_t' [-Wpedantic]
 typedef void void_fn_t();
              ^
dmcp/dmcp.h:285:14: note: previous declaration of 'void_fn_t' was here
 typedef void void_fn_t();
              ^
dmcp/sys/pgm_syscalls.c:52:25: error: C++ style comments are not allowed in ISO C90
  PROG_INFO_MAGIC,       // uint32_t pgm_magic;
                         ^
dmcp/sys/pgm_syscalls.c:52:25: error: (this will be reported only once per input file)
dmcp/sys/pgm_syscalls.c:54:2: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  (void*)Program_Entry,  // void * pgm_entry;
  ^
cc1: warning: unrecognized command line option "-Wno-misleading-indentation"
Makefile:131: recipe for target 'build/pgm_syscalls.o' failed
make: *** [build/pgm_syscalls.o] Error 1
What if you add -std=c99 or -std=c11?
Vitasam

Re: DMCP_SDK Hello World

Post by Vitasam »

ijabbott wrote:
Thu Jun 14, 2018 10:38 pm
What if you add -std=c99 or -std=c11?
But what is a policy of DM42 SDK - are we C99 compliant?

With following options:

Code: Select all

CFLAGS += -std=c99
CFLAGS += -pedantic-errors

Code: Select all

DMCP_SDK$ make
arm-none-eabi-gcc -c -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -Idmcp -Isrc   -Wall -fdata-sections -ffunction-sections -Wno-misleading-indentation -std=c99 -pedantic-errors -O2 -g  -MD -MP -MF .dep/pgm_syscalls.o.d -Wa,-a,-ad,-alms=build/pgm_syscalls.lst dmcp/sys/pgm_syscalls.c -o build/pgm_syscalls.o
In file included from dmcp/sys/pgm_syscalls.c:44:0:
dmcp/dmcp.h:474:14: error: redefinition of typedef 'void_fn_t' [-Wpedantic]
 typedef void void_fn_t();
              ^
dmcp/dmcp.h:285:14: note: previous declaration of 'void_fn_t' was here
 typedef void void_fn_t();
              ^
dmcp/sys/pgm_syscalls.c:54:2: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  (void*)Program_Entry,  // void * pgm_entry;
  ^
dmcp/sys/pgm_syscalls.c: In function 'free':
dmcp/sys/pgm_syscalls.c:113:2: error: implicit declaration of function 'typeof' [-Wimplicit-function-declaration]
  __sysfn_free(ptr);
  ^
In file included from dmcp/dmcp.h:841:0,
                 from dmcp/sys/pgm_syscalls.c:44:
dmcp/lft_ifc.h:38:38: error: expected expression before ')' token
 #define __sysfn_free (*(typeof(free)*)(LIBRARY_FN_BASE+4))
                                      ^
dmcp/sys/pgm_syscalls.c:113:2: note: in expansion of macro '__sysfn_free'
  __sysfn_free(ptr);
  ^
dmcp/sys/pgm_syscalls.c: In function 'malloc':
dmcp/lft_ifc.h:37:42: error: expected expression before ')' token
 #define __sysfn_malloc (*(typeof(malloc)*)(LIBRARY_FN_BASE+0))
                                          ^
dmcp/sys/pgm_syscalls.c:118:9: note: in expansion of macro '__sysfn_malloc'
  return __sysfn_malloc(size);
         ^
dmcp/sys/pgm_syscalls.c: In function 'calloc':
dmcp/lft_ifc.h:39:42: error: expected expression before ')' token
 #define __sysfn_calloc (*(typeof(calloc)*)(LIBRARY_FN_BASE+8))
                                          ^
dmcp/sys/pgm_syscalls.c:123:9: note: in expansion of macro '__sysfn_calloc'
  return __sysfn_calloc(count, nbytes);
         ^
dmcp/sys/pgm_syscalls.c: In function 'realloc':
dmcp/lft_ifc.h:40:44: error: expected expression before ')' token
 #define __sysfn_realloc (*(typeof(realloc)*)(LIBRARY_FN_BASE+12))
                                            ^
dmcp/sys/pgm_syscalls.c:127:9: note: in expansion of macro '__sysfn_realloc'
  return __sysfn_realloc(ptr, size);
         ^
dmcp/sys/pgm_syscalls.c: In function 'post_main':
dmcp/lft_ifc.h:105:52: error: expected expression before ')' token
 #define set_reset_magic (*(typeof(set_reset_magic)*)(LIBRARY_FN_BASE+272))
                                                    ^
dmcp/sys/pgm_syscalls.c:151:2: note: in expansion of macro 'set_reset_magic'
  set_reset_magic(RUN_DMCP_MAGIC);
  ^
dmcp/lft_ifc.h:173:40: error: expected expression before ')' token
 #define sys_reset (*(typeof(sys_reset)*)(LIBRARY_FN_BASE+544))
                                        ^
dmcp/sys/pgm_syscalls.c:152:2: note: in expansion of macro 'sys_reset'
  sys_reset();
  ^
/usr/include/newlib/stdlib.h: In function 'malloc':
dmcp/sys/pgm_syscalls.c:119:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/usr/include/newlib/stdlib.h: In function 'calloc':
dmcp/sys/pgm_syscalls.c:124:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/usr/include/newlib/stdlib.h: In function 'realloc':
dmcp/sys/pgm_syscalls.c:128:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
dmcp/sys/pgm_syscalls.c: At top level:
cc1: warning: unrecognized command line option "-Wno-misleading-indentation"
Makefile:132: recipe for target 'build/pgm_syscalls.o' failed
make: *** [build/pgm_syscalls.o] Error 1
Thomas_ER
Posts: 192
Joined: Mon Jul 24, 2017 3:19 pm
Location: Germany

Re: DMCP_SDK Hello World

Post by Thomas_ER »

Did someone build this "Hello World" (and/or the complete package) in an Windows (7) environment,
and could give some advice?
What would be a useful working environment?

Many thanks in advance!
[ HP48/49/50/42S/WP34/HP Prime/ DM42 (#00185+00318) ]
Vitasam

Re: DMCP_SDK Hello World

Post by Vitasam »

Thomas_ER wrote:
Fri Jun 15, 2018 7:49 am
Did someone build this "Hello World" (and/or the complete package) in an Windows (7) environment,
and could give some advice?
What would be a useful working environment?

Many thanks in advance!
Hi Thomas,
frankly speaking, SW development for embedded systems with GNU tools is much easier under Linux.
But sometimes there is no other choice, Windows only. I would suggest to use MinGW.

I just tested the build in Windows 10 MinGW environment:

Code: Select all

...
arm-none-eabi-objcopy --only-section   .qspi -O ihex    build/TESTPGM.elf  build/TESTPGM_qspi.hex
arm-none-eabi-objcopy --only-section   .qspi -O binary  build/TESTPGM.elf  build/TESTPGM_qspi.bin
bin/check_qspi_crc TESTPGM src/qspi_crc.h || ( make clean && false )
bin/add_pgm_chsum build/TESTPGM_flash.bin build/TESTPGM.pgm
FIND: Parameter format not correct
SHA1: 8d668604ee1fd16b96d5210e01469538bb2fb4d9*
arm-none-eabi-size build/TESTPGM.elf
   text    data     bss     dec     hex filename
    752    1088      64    1904     770 build/TESTPGM.elf

C:\Users\...\GITProjects\DMCP_SDK>

There is something wrong with hash calculations: FIND: Parameter format not correct, perhaps binary tools (add_pgm_chsum etc.) should be re-compiled for Windows too.

1) Install MinGW (http://mingw.org/)
There is a GUI installer tool for windows: https://sourceforge.net/projects/mingw/files/Installer/

2) Install GNU Arm Embedded Toolchain for Windows https://developer.arm.com/open-source/g ... /downloads

3) Create BAT file to set path in to console environment. I have setenv.bat:

Code: Select all

set PATH=%PATH%;C:\MinGW\msys\1.0\bin;C:\Program Files (x86)\GNU Tools ARM Embedded\7 2017-q4-major\bin
You can also add path in to Windows system environment variables, if you want. I do prefer to keep environment local for every project.

4) Clone DMCP_SDK GIT repository and copy setenv.bat file in to the project's folder

5) Open windows terminal, run setenv.bat and type make -v

Code: Select all

C:\Users\...\GITProjects\DMCP_SDK>make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-msys
If you don't have make you have to install it separately from http://gnuwin32.sourceforge.net/packages/make.htm and add path to it in to setenv.bat file
Thomas_ER
Posts: 192
Joined: Mon Jul 24, 2017 3:19 pm
Location: Germany

Re: DMCP_SDK Hello World

Post by Thomas_ER »

Hi Vitasam,

many thanks for your very helpful tipps!
I've successful installed MinGW and GNU Arm Embedded Toolchain, copied the github (via ZIP file, don't have Git installed),
in this try to C:\MinGW\, created the bat file. 'make -v' is also fine.

Trying 'make' resulted in an error regarding bin/check_qspi_crc

Code: Select all

...
arm-none-eabi-objcopy --remove-section .qspi -O ihex    build/TESTPGM.elf  build/TESTPGM_flash.hex
arm-none-eabi-objcopy --remove-section .qspi -O binary  build/TESTPGM.elf  build/TESTPGM_flash.bin
arm-none-eabi-objcopy --only-section   .qspi -O ihex    build/TESTPGM.elf  build/TESTPGM_qspi.hex
arm-none-eabi-objcopy --only-section   .qspi -O binary  build/TESTPGM.elf  build/TESTPGM_qspi.bin
bin/check_qspi_crc TESTPGM src/qspi_crc.h || ( make clean && false )
/usr/bin/sh: bin/check_qspi_crc: No such file or directory
make[1]: Entering directory `C:/MinGW/DMCP_SDK'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `C:/MinGW/DMCP_SDK'
make: *** [build/TESTPGM.elf] Error 1
The file 'check_qspi_crc' exists at C:\MinGW\DMCP_SDK\bin
Is there something i have to modify in the Makefile ?
[ HP48/49/50/42S/WP34/HP Prime/ DM42 (#00185+00318) ]
Vitasam

Re: DMCP_SDK Hello World

Post by Vitasam »

Thomas_ER wrote:
Fri Jun 15, 2018 12:53 pm
Hi Vitasam,

many thanks for your very helpful tipps!
I've successful installed MinGW and GNU Arm Embedded Toolchain, copied the github (via ZIP file, don't have Git installed),
in this try to C:\MinGW\, created the bat file. 'make -v' is also fine.

Trying 'make' resulted in an error regarding bin/check_qspi_crc

Code: Select all

...
arm-none-eabi-objcopy --remove-section .qspi -O ihex    build/TESTPGM.elf  build/TESTPGM_flash.hex
arm-none-eabi-objcopy --remove-section .qspi -O binary  build/TESTPGM.elf  build/TESTPGM_flash.bin
arm-none-eabi-objcopy --only-section   .qspi -O ihex    build/TESTPGM.elf  build/TESTPGM_qspi.hex
arm-none-eabi-objcopy --only-section   .qspi -O binary  build/TESTPGM.elf  build/TESTPGM_qspi.bin
bin/check_qspi_crc TESTPGM src/qspi_crc.h || ( make clean && false )
/usr/bin/sh: bin/check_qspi_crc: No such file or directory
make[1]: Entering directory `C:/MinGW/DMCP_SDK'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `C:/MinGW/DMCP_SDK'
make: *** [build/TESTPGM.elf] Error 1
The file 'check_qspi_crc' exists at C:\MinGW\DMCP_SDK\bin
Is there something i have to modify in the Makefile ?
Hi Thomas,

in which Windows terminal you are running make? Cygwin or something similar? There is a shell message
/usr/bin/sh: bin/check_qspi_crc: No such file or directory

I did test it just in Windows terminal (cmd)
Thomas_ER
Posts: 192
Joined: Mon Jul 24, 2017 3:19 pm
Location: Germany

Re: DMCP_SDK Hello World

Post by Thomas_ER »

Vitasam wrote:
Fri Jun 15, 2018 1:12 pm
Thomas_ER wrote:
Fri Jun 15, 2018 12:53 pm
Hi Vitasam,
...
Hi Thomas,

in which Windows terminal you are running make? Cygwin or something similar? There is a shell message
/usr/bin/sh: bin/check_qspi_crc: No such file or directory

I did test it just in Windows terminal (cmd)
I did it also in Windows terminal cmd, no Cygwin.

Now i moved the Github-Content from the MinGW directory to my users directory,
did am 'make clean', and another 'make', but i get the same error.

Found some hints regarding '/usr/bin/sh' at
https://stackoverflow.com/questions/478 ... on-windows,
but this didn't help.
[ HP48/49/50/42S/WP34/HP Prime/ DM42 (#00185+00318) ]
Post Reply