Compiling MicroPyton with IAR & Keil c compiler

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
UV100
Posts: 6
Joined: Mon May 22, 2017 4:25 pm

Compiling MicroPyton with IAR & Keil c compiler

Post by UV100 » Mon May 22, 2017 4:47 pm

Hi all

I will appreciate your kind help with this ,

I have try to compile Micropyton with IAR compiler for the same STM32F405 and encountered lots of Error (expected issue)

In the PY directory there are many file some compiled well and some compiled with lots of error's and warnings ,

I'm not sure which file needed to be compiled and which not ,as it is very hard to follow the nested make file,

can any one please upload a list of files needed for the micropyton to run under the STM32F405 ARM controller (full)

Including the file in the STMHAL ,PY ,and Bare-arm and probably other directories (not sure whether there are )

Thank you

UV100

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by dhylands » Mon May 22, 2017 6:19 pm

Here;'s the output of doing a clean build:

Code: Select all

Executing GNUmakefile
BOARD = PYBV10
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-PYBV10/genhdr
Create build-PYBV10/genhdr/pins.h
Create stmconst build-PYBV10/modstm_qstr.h
Create build-PYBV10/genhdr/pybcdc.inf
Create build-PYBV10/genhdr/pybcdc_inf.h
Generating build-PYBV10/genhdr/mpversion.h
GEN build-PYBV10/genhdr/qstr.i.last
GEN build-PYBV10/genhdr/qstr.split
GEN build-PYBV10/genhdr/qstrdefs.collected.h
QSTR updated
GEN build-PYBV10/genhdr/qstrdefs.generated.h
mkdir -p build-PYBV10/build-PYBV10
mkdir -p build-PYBV10/drivers/memory
mkdir -p build-PYBV10/hal/f4/src
mkdir -p build-PYBV10/lib/libc
mkdir -p build-PYBV10/lib/libm
mkdir -p build-PYBV10/lib/mp-readline
mkdir -p build-PYBV10/lib/netutils
mkdir -p build-PYBV10/lib/oofatfs
mkdir -p build-PYBV10/lib/oofatfs/option
mkdir -p build-PYBV10/lib/timeutils
mkdir -p build-PYBV10/lib/utils
mkdir -p build-PYBV10/py
mkdir -p build-PYBV10/py/../extmod
mkdir -p build-PYBV10/py/../lib/embed
mkdir -p build-PYBV10/usbdev/class/src
mkdir -p build-PYBV10/usbdev/core/src
CC ../py/mpstate.c
CC ../py/nlrx86.c
CC ../py/nlrx64.c
CC ../py/nlrthumb.c
CC ../py/nlrxtensa.c
CC ../py/nlrsetjmp.c
CC ../py/malloc.c
CC ../py/gc.c
CC ../py/qstr.c
CC ../py/vstr.c
CC ../py/mpprint.c
CC ../py/unicode.c
CC ../py/mpz.c
CC ../py/reader.c
CC ../py/lexer.c
CC ../py/parse.c
CC ../py/scope.c
CC ../py/compile.c
CC ../py/emitcommon.c
CC ../py/emitbc.c
CC ../py/asmbase.c
CC ../py/asmx64.c
CC ../py/emitnative.c
CC ../py/asmx86.c
CC ../py/emitnative.c
CC ../py/asmthumb.c
CC ../py/emitnative.c
CC ../py/emitinlinethumb.c
CC ../py/asmarm.c
CC ../py/emitnative.c
CC ../py/asmxtensa.c
CC ../py/emitnative.c
CC ../py/emitinlinextensa.c
CC ../py/formatfloat.c
CC ../py/parsenumbase.c
CC ../py/parsenum.c
CC ../py/emitglue.c
CC ../py/persistentcode.c
CC ../py/runtime.c
CC ../py/runtime_utils.c
CC ../py/scheduler.c
CC ../py/nativeglue.c
CC ../py/stackctrl.c
CC ../py/argcheck.c
CC ../py/warning.c
CC ../py/map.c
CC ../py/obj.c
CC ../py/objarray.c
CC ../py/objattrtuple.c
CC ../py/objbool.c
CC ../py/objboundmeth.c
CC ../py/objcell.c
CC ../py/objclosure.c
CC ../py/objcomplex.c
CC ../py/objdict.c
CC ../py/objenumerate.c
CC ../py/objexcept.c
CC ../py/objfilter.c
CC ../py/objfloat.c
CC ../py/objfun.c
CC ../py/objgenerator.c
CC ../py/objgetitemiter.c
CC ../py/objint.c
CC ../py/objint_longlong.c
CC ../py/objint_mpz.c
CC ../py/objlist.c
CC ../py/objmap.c
CC ../py/objmodule.c
CC ../py/objobject.c
CC ../py/objpolyiter.c
CC ../py/objproperty.c
CC ../py/objnone.c
CC ../py/objnamedtuple.c
CC ../py/objrange.c
CC ../py/objreversed.c
CC ../py/objset.c
CC ../py/objsingleton.c
CC ../py/objslice.c
CC ../py/objstr.c
CC ../py/objstrunicode.c
CC ../py/objstringio.c
CC ../py/objtuple.c
CC ../py/objtype.c
CC ../py/objzip.c
CC ../py/opmethods.c
CC ../py/sequence.c
CC ../py/stream.c
CC ../py/binary.c
CC ../py/builtinimport.c
CC ../py/builtinevex.c
CC ../py/builtinhelp.c
CC ../py/modarray.c
CC ../py/modbuiltins.c
CC ../py/modcollections.c
CC ../py/modgc.c
CC ../py/modio.c
CC ../py/modmath.c
CC ../py/modcmath.c
CC ../py/modmicropython.c
CC ../py/modstruct.c
CC ../py/modsys.c
CC ../py/moduerrno.c
CC ../py/modthread.c
CC ../py/vm.c
CC ../py/bc.c
CC ../py/showbc.c
CC ../py/repl.c
CC ../py/smallint.c
CC ../py/frozenmod.c
CC ../py/../extmod/moductypes.c
CC ../py/../extmod/modujson.c
CC ../py/../extmod/modure.c
CC ../py/../extmod/moduzlib.c
CC ../py/../extmod/moduheapq.c
CC ../py/../extmod/modutimeq.c
CC ../py/../extmod/moduhashlib.c
CC ../py/../extmod/modubinascii.c
CC ../py/../extmod/virtpin.c
CC ../py/../extmod/machine_mem.c
CC ../py/../extmod/machine_pinbase.c
CC ../py/../extmod/machine_signal.c
CC ../py/../extmod/machine_pulse.c
CC ../py/../extmod/machine_i2c.c
CC ../py/../extmod/machine_spi.c
CC ../py/../extmod/modussl_axtls.c
CC ../py/../extmod/modussl_mbedtls.c
CC ../py/../extmod/modurandom.c
CC ../py/../extmod/moduselect.c
CC ../py/../extmod/modwebsocket.c
CC ../py/../extmod/modwebrepl.c
CC ../py/../extmod/modframebuf.c
CC ../py/../extmod/vfs.c
CC ../py/../extmod/vfs_reader.c
CC ../py/../extmod/vfs_fat.c
CC ../py/../extmod/vfs_fat_diskio.c
CC ../py/../extmod/vfs_fat_file.c
CC ../py/../extmod/vfs_fat_misc.c
CC ../py/../extmod/utime_mphal.c
CC ../py/../extmod/uos_dupterm.c
CC ../py/../lib/embed/abort_.c
CC ../py/../lib/utils/printf.c
MPY modules/lcd160cr.py
MPY modules/lcd160cr_test.py
MPY modules/lib/hello.py
MPY modules/main.py
Creating build-PYBV10/frozen_mpy.c
CC build-PYBV10/frozen_mpy.c
CC ../lib/libc/string0.c
CC ../lib/libm/math.c
CC ../lib/libm/thumb_vfp_sqrtf.c
CC ../lib/libm/asinfacosf.c
CC ../lib/libm/atanf.c
CC ../lib/libm/atan2f.c
CC ../lib/libm/fmodf.c
CC ../lib/libm/nearbyintf.c
CC ../lib/libm/log1pf.c
CC ../lib/libm/acoshf.c
CC ../lib/libm/asinhf.c
CC ../lib/libm/atanhf.c
CC ../lib/libm/kf_rem_pio2.c
CC ../lib/libm/kf_sin.c
CC ../lib/libm/kf_cos.c
CC ../lib/libm/kf_tan.c
CC ../lib/libm/ef_rem_pio2.c
CC ../lib/libm/erf_lgamma.c
CC ../lib/libm/sf_sin.c
CC ../lib/libm/sf_cos.c
CC ../lib/libm/sf_tan.c
CC ../lib/libm/sf_frexp.c
CC ../lib/libm/sf_modf.c
CC ../lib/libm/sf_ldexp.c
CC ../lib/libm/sf_erf.c
CC ../lib/libm/wf_lgamma.c
CC ../lib/libm/wf_tgamma.c
CC ../lib/oofatfs/ff.c
CC ../lib/oofatfs/option/unicode.c
CC ../lib/mp-readline/readline.c
CC ../lib/netutils/netutils.c
CC ../lib/timeutils/timeutils.c
CC ../lib/utils/pyexec.c
CC ../lib/utils/interrupt_char.c
CC ../drivers/memory/spiflash.c
CC main.c
CC system_stm32.c
CC stm32_it.c
CC usbd_conf.c
CC usbd_desc.c
CC usbd_cdc_interface.c
CC usbd_hid_interface.c
CC usbd_msc_storage.c
CC mphalport.c
CC mpthreadport.c
CC irq.c
CC pendsv.c
CC systick.c
CC pybthread.c
CC timer.c
CC led.c
CC pin.c
CC pin_defs_stmhal.c
CC pin_named_pins.c
CC bufhelper.c
CC dma.c
CC i2c.c
CC spi.c
CC uart.c
CC can.c
CC usb.c
CC wdt.c
CC gccollect.c
CC pybstdio.c
CC help.c
CC input.c
CC machine_i2c.c
CC modmachine.c
CC modpyb.c
CC modstm.c
CC moduos.c
CC modutime.c
CC modusocket.c
CC modnetwork.c
CC extint.c
CC usrsw.c
CC rng.c
CC rtc.c
CC flash.c
CC storage.c
CC sdcard.c
CC fatfs_port.c
CC lcd.c
CC accel.c
CC servo.c
CC dac.c
CC adc.c
CC startup_stm32.S
AS gchelper.s
CC hal/f4/src/stm32f4xx_hal.c
CC hal/f4/src/stm32f4xx_hal_adc.c
CC hal/f4/src/stm32f4xx_hal_adc_ex.c
CC hal/f4/src/stm32f4xx_hal_can.c
CC hal/f4/src/stm32f4xx_hal_cortex.c
CC hal/f4/src/stm32f4xx_hal_dac.c
CC hal/f4/src/stm32f4xx_hal_dac_ex.c
CC hal/f4/src/stm32f4xx_hal_dma.c
CC hal/f4/src/stm32f4xx_hal_flash.c
CC hal/f4/src/stm32f4xx_hal_flash_ex.c
CC hal/f4/src/stm32f4xx_hal_gpio.c
CC hal/f4/src/stm32f4xx_hal_i2c.c
CC hal/f4/src/stm32f4xx_hal_pcd.c
CC hal/f4/src/stm32f4xx_hal_pcd_ex.c
CC hal/f4/src/stm32f4xx_hal_pwr.c
CC hal/f4/src/stm32f4xx_hal_pwr_ex.c
CC hal/f4/src/stm32f4xx_hal_rcc.c
CC hal/f4/src/stm32f4xx_hal_rcc_ex.c
CC hal/f4/src/stm32f4xx_hal_rng.c
CC hal/f4/src/stm32f4xx_hal_rtc.c
CC hal/f4/src/stm32f4xx_hal_rtc_ex.c
CC hal/f4/src/stm32f4xx_hal_sd.c
CC hal/f4/src/stm32f4xx_hal_spi.c
CC hal/f4/src/stm32f4xx_hal_tim.c
CC hal/f4/src/stm32f4xx_hal_tim_ex.c
CC hal/f4/src/stm32f4xx_hal_uart.c
CC hal/f4/src/stm32f4xx_ll_sdmmc.c
CC hal/f4/src/stm32f4xx_ll_usb.c
CC usbdev/core/src/usbd_core.c
CC usbdev/core/src/usbd_ctlreq.c
CC usbdev/core/src/usbd_ioreq.c
CC usbdev/class/src/usbd_cdc_msc_hid.c
CC usbdev/class/src/usbd_msc_bot.c
CC usbdev/class/src/usbd_msc_scsi.c
CC usbdev/class/src/usbd_msc_data.c
CC build-PYBV10/pins_PYBV10.c
LINK build-PYBV10/firmware.elf
   text	   data	    bss	    dec	    hex	filename
 321268	    352	  28088	 349708	  5560c	build-PYBV10/firmware.elf
Create build-PYBV10/firmware.dfu
Create build-PYBV10/firmware.hex

UV100
Posts: 6
Joined: Mon May 22, 2017 4:25 pm

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by UV100 » Tue May 23, 2017 2:18 pm

Thank you for the kind help

UV100

UV100
Posts: 6
Joined: Mon May 22, 2017 4:25 pm

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by UV100 » Sun May 28, 2017 1:18 pm

Hi

There are some missing header files under a directory called "genhdr" who is also missed:

Create stmconst build-PYBV10/modstm_qstr.h
Create build-PYBV10/genhdr/pybcdc.inf
Create build-PYBV10/genhdr/pybcdc_inf.h
Generating build-PYBV10/genhdr/mpversion.h
GEN build-PYBV10/genhdr/qstr.i.last
GEN build-PYBV10/genhdr/qstr.split
GEN build-PYBV10/genhdr/qstrdefs.collected.h

(this files are created & precompiled in the make process)

What is the purposes of this files?
how to create them for other compilers?
or where to get them ?

as they are not on the upyton pack

Can anyone please help

Thank you

UV100

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by stijn » Sun May 28, 2017 2:10 pm

They're generated by a mix of python code (makeqstrdata.py) and invoking the C preprocessor. See https://github.com/micropython/micropyt ... py.mk#L278

UV100
Posts: 6
Joined: Mon May 22, 2017 4:25 pm

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by UV100 » Sun May 28, 2017 4:28 pm

I have try to use a pregenerated files but the compiler produce lot's of errors

What is the purposes of this files?

Dose it need to be generated for every compiler and every build? - why?

Please help

Thanks

UV100

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by stijn » Sun May 28, 2017 7:10 pm

MicroPython uses string interning, purpose of this preprocessing which must basically be done after any change to any of the source files is to scan the source for identifiers like MP_QSTR_xxx and then add the representation for string xxx to the header qstrdefs.generated.h. Which in turn is included by the code, so it can resolve MP_QSTR_xxx to the actual string. I'm not sure if you can use another compiler to generate it than the one you're using for building te source.
mpversion.h is another generated header, generated by makeversionhdr.py.

But can't you use the existing makefiles, eventually adding some tweaks? Or at least parts of it? It might be less work than rewriting major parts from scratch.

blipton
Posts: 8
Joined: Mon Dec 15, 2014 3:11 am

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by blipton » Sun Feb 11, 2018 5:00 am

UV100 did you have any success compiling in keil?

Gnu's make is so different than the uvision flow that it would seem impossible

UV100
Posts: 6
Joined: Mon May 22, 2017 4:25 pm

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by UV100 » Sun Feb 11, 2018 10:44 am

Hi

I have abandon this project due to the complexity of transferring some files (macro's) from Gnu to IAR
This software was not written with professional software engineering in mind and it needs quit lot of work to transfer to another programming environment.
Hope someone ells have time to transfer it to a professional working environment (keill or IAR) as it can benefit many other's

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Compiling MicroPyton with IAR & Keil c compiler

Post by stijn » Sun Feb 11, 2018 11:54 am

UV100 wrote:
Sun Feb 11, 2018 10:44 am
This software was not written with professional software engineering in mind
With all due respect, sorry but that is nonsense. Your claim seems to be "this project doesn't work with my particular toolset so it's bad". Thereby ignoring it does work with a myriad of other, more widespread toolsets. Please correct me if I'm wrong.

It was written for C99. Any proper compiler supporting most of C99 can be used. As such, MicroPython can be compiled with clang, gcc and msvc. And possibly others which weren't tested. To get around some platform/compiler specifics, some parts will be compiled conditionally. Now obvisouly the authors do not have time nor money to buy and test with every single possible comiler out there. So if a new compiler needs to be used possibly some things need adjusting. Calling that a lack of "professional software engineering" is simply incorrect.

Same story for the generation of the header files: written originally to work with a few select compilers, mainly gcc. It took me a relatively small amount of time to get it to work msvc. So instead of complaining there was a lack of professionalism, to me this actually showed the opposite: because of the way this was implemented I could easily get it to work with a completely different compiler than gcc.

Now that was just about compilers. On to the build system. The authors chose gnu make. Not a bad choice seeing how widespread gnu make is. Calling that a lack of "professional software engineering" simply because gnu make does not happen to be that particular - possibly rather obscure - buildsystem which you use yourself, is again incorrect. It would be the same as calling out your project being unprofessional for not using gnu make. Also incorrect. And again note that getting the whole project building and running with a completely different system, msbuild instead of make, was relatively easy. So transferring it to use some other toolset is definitely possible.

Post Reply