Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental branch to add support for GCC and ARMCLANG #750

Merged
merged 99 commits into from
Jan 27, 2021

Conversation

mbrossard
Copy link
Contributor

@mbrossard mbrossard commented Dec 17, 2020

I would like to merge to this experimental branch the work @flit and I have been doing to to add support for Arm GCC (#197) and armclang (#644). It should also address #580 with the switch to RTX5.

By merging into a branch of the main repository we hope to get some feedback, testing (automated and otherwise) and fixes.

This branch requires project-generator/project_generator#474 to compile.

Build instruction (Linux and Mac)

Install dependencies

$ virtualenv venv
$ source ./venv/bin/activate
(venv) $ pip install -r requirements.txt
(venv) $ pip install -U git+https://github.com/mbrossard/project_generator.git@development

Build images

You can use the progen command-line tool from project-generator or the following wrapper tool:

(venv) $ ./tools/progen_compile.py [-t <tool>] [--clean] [-v] [--parallel] [<project> [<project> ...]]
  • -t <tool>: choose the toolchain to build. The default is make_gcc_arm and the ones I have been testing with are make_gcc_arm, make_armcc, make_armclang, cmake_gcc_arm, cmake_armcc, cmake_armclang.
  • --clean: will clear existing compilation products and force recompilation of all files.
  • -v: will make compilation process more verbose (typically listing all commands with their arguments)
  • --parallel: enable parallel compilation within a project (projects are compiled sequentially).
  • <project>: target project to compile (e.g. stm32f103xb_bl, lpc11u35_if), if none is specified all (140 to 150) projects will be compiled.

Build instructions (Windows)

This branch has received much smaller amount of testing on Windows. As an example, the following instructions build stm32f103xb_if:

> choco install python make gcc-arm-embedded git
> refreshenv
> pip install --user virtualenv

> git clone -b experimental https://github.com/mbrossard/DAPLink.git
> cd DAPLink
> python -m virtualenv venv
> .\venv\Scripts\activate.bat
(venv) > pip install --user -r requirements.txt
(venv) > pip uninstall -y project-generator
(venv) > pip install --upgrade --user git+https://github.com/mbrossard/project_generator.git@development
(venv) > python tools\progen_compile.py --clean -v stm32f103xb_if

gerargz and others added 9 commits August 20, 2020 10:37
Modify yamls to point to kl27 and microbit v2 board files
Change KL27 interface flash size to 128KB and RAM to 32KB
Adapt UART driver to LPUART peripheral and add clock drivers
Change KL27 device specific header files based on NXP SDK
Add HIC and board info to info.py
Removed "reserving for future use" comment on the DAPLINK_HIC_ID_KL27Z definition.
…tches IO_PORT_WRITE_CYCLES of 1 in DAP_config.h
* Allow all support baud rates
* Fix RX FIFO overflow issue
* Fix mask name for interrupt enable of RX overflow
This was referenced Dec 17, 2020
@cederom
Copy link
Contributor

cederom commented Dec 17, 2020

Awsome! Congratulations :-) Would you guys first merge this into upstream or prefer to get some testing before merge?

First impressions:

  1. Project generation:
  • progen does not accept -p paremeter but works without thisparameter anyways.
  • there seems to be lots of outputs and warnings
(venv-37-zephyr) progen generate -t make_gcc_arm -p gcctest
root ERROR      You specified an invalid project name.

(venv-37-zephyr) progen generate -t make_gcc_arm
(..)
progen.project ERROR    Project data {'common': {'target': ['stm32f103xb'], 'core': ['Cortex-M3'], 'macros': ['INTERFACE_STM32F103XB', 'USE_HAL_DRIVER', 'STM32F103xB', 'DAPLINK_HIC_ID=0x97969908', '__packed=__packed', 'DAPLINK_NO_ASSERT_FILENAMES', 'OS_CLOCK=72000000'], 'includes': ['source/hic_hal/stm32/stm32f103xb', 'source/hic_hal/stm32/stm32f103xb/cmsis', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver/Inc'], 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb', 'source/hic_hal/stm32/stm32f103xb/cmsis', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver/Src']}}, 'tool_specific': {'uvision': {'misc': {'ld_flags': ['--predefine="-I..\\..\\..\\source\\hic_hal\\stm32\\stm32f103xb"']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'armcc': {'misc': {'ld_flags': ['--predefine="-Isource\\hic_hal\\stm32\\stm32f103xb"']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'armclang': {'misc': {'c_flags': ['-mcpu=cortex-m3'], 'asm_flags': ['-mcpu=cortex-m3']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'gcc_arm': {'includes': ['source/hic_hal/stm32/stm32f103xb/gcc'], 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/gcc']}}}} contain non-valid tool: armcc
progen.project ERROR    Project data {'common': {'target': ['stm32f103xb'], 'core': ['Cortex-M3'], 'macros': ['INTERFACE_STM32F103XB', 'USE_HAL_DRIVER', 'STM32F103xB', 'DAPLINK_HIC_ID=0x97969908', '__packed=__packed', 'DAPLINK_NO_ASSERT_FILENAMES', 'OS_CLOCK=72000000'], 'includes': ['source/hic_hal/stm32/stm32f103xb', 'source/hic_hal/stm32/stm32f103xb/cmsis', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver/Inc'], 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb', 'source/hic_hal/stm32/stm32f103xb/cmsis', 'source/hic_hal/stm32/stm32f103xb/STM32F1xx_HAL_Driver/Src']}}, 'tool_specific': {'uvision': {'misc': {'ld_flags': ['--predefine="-I..\\..\\..\\source\\hic_hal\\stm32\\stm32f103xb"']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'armcc': {'misc': {'ld_flags': ['--predefine="-Isource\\hic_hal\\stm32\\stm32f103xb"']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'armclang': {'misc': {'c_flags': ['-mcpu=cortex-m3'], 'asm_flags': ['-mcpu=cortex-m3']}, 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/armcc']}}, 'gcc_arm': {'includes': ['source/hic_hal/stm32/stm32f103xb/gcc'], 'sources': {'hic_hal': ['source/hic_hal/stm32/stm32f103xb/gcc']}}}} contain non-valid tool: armclang
progen.generate INFO    Generating make_gcc_arm for stm32f103xb_ublox_evk_odin_w2_if
  1. Build
  • I have to enter specific Target-HIC location in order to build.
  • No top level Makefile to build all firmwares.
  • I have to use gmake (GNU Make) not make (BSD Make) on FreeBSD.
  • Something starts to build but some header seems to be missing :-)
(venv-37-zephyr) gmake
/bin/sh: ../../../tools/pre_build_script.sh: not found
Preprocessing ../../../source/daplink/daplink.ld
Compiling ../../../source/board/mkit_dk_dongle_nrf5x.c
Compiling ../../../source/daplink/HardFault_Handler.c
Compiling ../../../source/daplink/circ_buf.c
Compiling ../../../source/daplink/cmsis-dap/DAP.c
Compiling ../../../source/daplink/cmsis-dap/DAP_queue.c
Compiling ../../../source/daplink/cmsis-dap/DAP_vendor.c
Compiling ../../../source/daplink/cmsis-dap/JTAG_DP.c
Compiling ../../../source/daplink/cmsis-dap/SWO.c
Compiling ../../../source/daplink/cmsis-dap/SW_DP.c
Compiling ../../../source/daplink/cortex_m.c
Compiling ../../../source/daplink/crc16.c
Compiling ../../../source/daplink/crc32.c
Compiling ../../../source/daplink/drag-n-drop/file_stream.c
Compiling ../../../source/daplink/drag-n-drop/flash_decoder.c
Compiling ../../../source/daplink/drag-n-drop/flash_intf.c
Compiling ../../../source/daplink/drag-n-drop/flash_manager.c
Compiling ../../../source/daplink/drag-n-drop/iap_flash_intf.c
Compiling ../../../source/daplink/drag-n-drop/intelhex.c
Compiling ../../../source/daplink/drag-n-drop/vfs_manager.c
../../../source/daplink/drag-n-drop/vfs_manager.c:34:10: fatal error: version_git.h: No such file or directory
   34 | #include "version_git.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake: *** [Makefile:213: build/vfs_manager.o] Error 1

My environment details below. GCC does work well for building MBED and ZEPHYR firmwares.

(venv-37-zephyr) uname -a
FreeBSD 0xCFMX4 12.2-RELEASE-p1 FreeBSD 12.2-RELEASE-p1 GENERIC  amd64

(venv-37-zephyr) which python
/home/cd/usr/local/test/venv-37-zephyr/bin/python

(venv-37-zephyr) python --version
Python 3.7.9

(venv-37-zephyr) arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-arm-embedded-9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/lto-wrapper
Target: arm-none-eabi
Configured with: /wrkdirs/usr/ports/devel/gcc-arm-embedded/work/gcc-arm-none-eabi-9-2020-q2-update/src/gcc/configure --target=arm-none-eabi --prefix=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update --infodir=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/share/doc/gcc-arm-none-eabi/info --mandir=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/share/doc/gcc-arm-none-eabi/man --htmldir=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/share/doc/gcc-arm-none-eabi/html --pdfdir=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/share/doc/gcc-arm-none-eabi/pdf --libexecdir=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/lib --with-gmp=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install --with-mpfr=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install --with-mpc=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install --with-isl=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install --with-libelf=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/wrkdirs/usr/ports/devel/gcc-arm-embedded/work/install/gcc-arm-embedded-9-2020-q2-update/arm-none-eabi --with-multilib-list=rmprofile --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain'
Thread model: single
gcc version 9.3.1 20200408 (release) (GNU Arm Embedded Toolchain) 

@mbrossard
Copy link
Contributor Author

Thank you for the feedback.

  1. Configuring

The following part of the error message hint that this might not be the right version of progen that is being run:

[...] contain non-valid tool: armcc
[...] contain non-valid tool: armclang

Once you have the virtualenv installed and activated (this is for the branch that also support CMake, but you can also use feature/armclang):

$ pip uninstall -y project-generator
$ pip install git+https://github.com/mbrossard/project_generator.git@feature/cmake

The following command should work without warnings or errors and list the projects (I don't know gcctest from you message):

$ progen list -f projects.yaml projects
k20dx_bl
k20dx_ep_agora_if
k20dx_ep_kairos_if
k20dx_frdmk20dx_if
[...]
  1. Building

I will take the example of stm32f103xb_if.

progen.generate INFO	Generating make_gcc_arm for stm32f103xb_if
$ make -C projectfiles/make_gcc_arm/stm32f103xb_if
Preprocessing ../../../source/daplink/daplink.ld
Compiling ../../../source/daplink/HardFault_Handler.c
[...]

Adding the -b flag to progen generate calls make but that will not work in your case.

The error fatal error: version_git.h: No such file or directory is related to /bin/sh: ../../../tools/pre_build_script.sh: not found. Without knowing the current working directory it is difficult to know what the issue is. Adding VERBOSE=1 on the make command gives additional output.

  1. Extra

If make is a problem, you might want to try the CMake/Ninja option (that is still being developed)

progen.generate INFO	Generating cmake_gcc_arm for stm32f103xb_if
$ cmake -G Ninja -S projectfiles/cmake_gcc_arm/stm32f103xb_if -B projectfiles/cmake_gcc_arm/stm32f103xb_if/build
-- The C compiler identification is GNU 9.3.1
-- The CXX compiler identification is GNU 9.3.1
-- The ASM compiler identification is GNU
[...]
$ ninja -C projectfiles/cmake_gcc_arm/stm32f103xb_if/build

Or try the all-in-one command:

$ USE_NINJA=1 progen generate -t cmake_gcc_arm -p stm32f103xb_if -b

@cederom
Copy link
Contributor

cederom commented Dec 17, 2020

Hey @mbrossard :-)

Progen

  • A specific version of progen needs to be use and it works with no warnings when listing and generating projects I can confirm, thanks :-)

Build

Missing Header

  • verbose build output below:
(venv-37-zephyr) gmake -C projectfiles/make_gcc_arm/sam3u2c_mkit_dk_dongle_nrf5x_if VERBOSE=1
gmake: Entering directory '/XXX/arm/mbed/DAPLink/mbrossard-daplink.git/projectfiles/make_gcc_arm/sam3u2c_mkit_dk_dongle_nrf5x_if'
/bin/sh: ../../../tools/pre_build_script.sh: not found
Compiling ../../../source/daplink/drag-n-drop/vfs_manager.c
arm-none-eabi-gcc -Os  -g3  -Werror  -ffunction-sections  -fdata-sections  -std=gnu99  -fshort-wchar  -fno-common  -ffreestanding  -fverbose-asm  -mno-unaligned-access  -Wa,-adln=build/vfs_manager.o.lst  -mcpu=cortex-m3 -mthumb  -I.  -I../../../source/usb  -I../../../source/daplink/cmsis-dap  -I../../../source/daplink/drag-n-drop  -I../../../source/daplink/usb2uart  -I../../../source/daplink/settings  -I../../../source/daplink  -I../../../source/daplink/interface  -I../../../source/cmsis-core  -I../../../source/hic_hal  -I../../../source/target  -I../../../source/rtos/Include  -I../../../source/rtos/RTX/Include  -I../../../source/hic_hal/atmel/sam3u2c  -I../../../source/board/override_mkit_dk_dongle_nrf5x  -I../../../source/hic_hal/atmel/sam3u2c/gcc -DDAPLINK_VERSION=254  -DHID_ENDPOINT  -DMSC_ENDPOINT  -DCDC_ENDPOINT  -DWEBUSB_INTERFACE  -DWINUSB_INTERFACE  -DDRAG_N_DROP_SUPPORT  -DDAPLINK_IF  -DDAPLINK_BUILD_KEY=0x9B939E8F  -DOS_TICK=10000  -DINTERFACE_SAM3U2C  -D__SAM3U2C__  -DDAPLINK_HIC_ID=0x97969903  -DOS_CLOCK=96000000  -DIO_CONFIG_OVERRIDE  -c -MMD -MP ../../../source/daplink/drag-n-drop/vfs_manager.c -o build/vfs_manager.o
../../../source/daplink/drag-n-drop/vfs_manager.c:34:10: fatal error: version_git.h: No such file or directory
   34 | #include "version_git.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
gmake: *** [Makefile:214: build/vfs_manager.o] Error 1
gmake: Leaving directory '/XXX/arm/mbed/DAPLink/mbrossard-daplink.git/projectfiles/make_gcc_arm/sam3u2c_mkit_dk_dongle_nrf5x_if'
  • I am working from a top level of the git repo. Yesterday I was working form a project generated working directory. This header is not anywhere in the project at beginning. It is supposed to be generated by tools/pre_build_script.sh which needs update, as it uses Linux specific construct of #!/bin/bash (only Linux treats /bin/bash as /bin/sh while these are two different shells), I would strongly recommend using raw and portable #!/bin/sh for scripting or #!/usr/bin/env bash and then set -e when bash is really mandatory but bash is not a standard package on Unix systems :-)
  • Running the script from pre_build_sctipt.sh by hand produces missing version_git.h:
venv-37-zephyr) pwd
/XXX/arm/mbed/DAPLink/mbrossard-daplink.git
(venv-37-zephyr) python tools/pre_build_script.py --version_git_dir=source/daplink/
#> Pre-build script start
#> Getting git SHA
#> Checking for local changes
#> Writing git version file
#> Pre-build script completed written source/daplink/version_git.h

Make

  • Then firmware compilation workds fine! :-)
Linking build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf
arm-none-eabi-gcc  -o build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf  build/mkit_dk_dongle_nrf5x.o build/HardFault_Handler.o build/circ_buf.o build/DAP.o build/DAP_queue.o build/DAP_vendor.o build/JTAG_DP.o build/SWO.o build/SW_DP.o build/cortex_m.o build/crc16.o build/crc32.o build/file_stream.o build/flash_decoder.o build/flash_intf.o build/flash_manager.o build/iap_flash_intf.o build/intelhex.o build/vfs_manager.o build/vfs_user.o build/virtual_fs.o build/error.o build/flash_hal.o build/info.o build/bootloader_update.o build/daplink.o build/main.o build/swd_host.o build/swd_host_ca.o build/target_flash.o build/sdk_stub.o build/settings.o build/settings_rom.o build/usbd_user_cdc_acm.o build/util.o build/validation.o build/target.o build/target_reset_nrf51.o build/target_reset_nrf52.o build/flash_hal_SAM3U.o build/gpio.o build/read_uid.o build/system_SAM3U.o build/uart.o build/usb_config.o build/usbd_ATSAM3U2C.o build/RTX_Config.o build/rtx_delay.o build/rtx_kernel.o build/rtx_lib.o build/rtx_memory.o build/rtx_mempool.o build/rtx_msgqueue.o build/rtx_mutex.o build/rtx_system.o build/rtx_thread.o build/rtx_timer.o build/os_systick.o build/target_board.o build/target_family.o build/usbd_cdc_acm.o build/usbd_core_cdc.o build/usbd_core_hid.o build/usbd_hid.o build/usbd_user_hid.o build/usbd_core_msc.o build/usbd_msc.o build/usbd_core.o build/usbd_core_webusb.o build/usbd_core_winusb.o  build/startup_SAM3U.o build/irq_cm3.o  -lm  -lgcc  -lc  -lnosys  --specs=nano.specs  --specs=nosys.specs  -Wl,-check-sections  -Wl,--defsym=__stack_size__=0x200  -Wl,--defsym=__heap_size__=0x0  -Wl,-fatal-warnings  -Wl,--gc-sections  -Wl,--no-wchar-size-warning  -Wl,--print-memory-usage  -Os  -g3  -Werror  -ffunction-sections  -fdata-sections  -std=gnu99  -fshort-wchar  -fno-common  -ffreestanding  -fverbose-asm  -mno-unaligned-access  -Wa,-adln=build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf.lst  -mcpu=cortex-m3 -mthumb -Wl,-Map=build/sam3u2c_mkit_dk_dongle_nrf5x_if.map,--cref -Tbuild/sam3u2c_mkit_dk_dongle_nrf5x_if.generated.ld
Memory region         Used Size  Region Size  %age Used
    m_interrupts:          1 KB         1 KB    100.00%
          m_text:         91 KB        91 KB    100.00%
        m_cfgrom:           9 B         4 KB      0.22%
          m_data:       14152 B      32512 B     43.53%
        m_cfgram:         142 B        256 B     55.47%
arm-none-eabi-size --totals build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf
   text    data     bss     dec     hex filename
  54528   39680   12399  106607   1a06f build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf
  54528   39680   12399  106607   1a06f (TOTALS)
arm-none-eabi-nm -n -f posix -C -l build/sam3u2c_mkit_dk_dongle_nrf5x_if.elf > build/sam3u2c_mkit_dk_dongle_nrf5x_if-symbol-table.txt
Converting build/sam3u2c_mkit_dk_dongle_nrf5x_if.hex
Converting build/sam3u2c_mkit_dk_dongle_nrf5x_if.bin
../../../tools/post_build_script_gcc.sh &&  true
/bin/sh: ../../../tools/post_build_script_gcc.sh: not found
gmake: *** [Makefile:250: all] Error 127
gmake: Leaving directory '/XXX/arm/mbed/DAPLink/mbrossard-daplink.git/projectfiles/make_gcc_arm/sam3u2c_mkit_dk_dongle_nrf5x_if'
  • Again the shell scripts needs an interpreter update but we know the issue and solution :-)

CMake

(venv-37-zephyr) USE_NINJA=1 progen generate -t cmake_gcc_arm -p stm32f103xb_if -b
progen.generate INFO    Generating cmake_gcc_arm for stm32f103xb_if
-- The C compiler identification is GNU 9.3.1
-- The CXX compiler identification is GNU 9.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Build files have been written to: /home/cd/cederom/work/CeDeROM/lab/embedded/arm/mbed/DAPLink/mbrossard-daplink.git/projectfiles/cmake_gcc_arm/stm32f103xb_if/build
ninja: Entering directory `projectfiles/cmake_gcc_arm/stm32f103xb_if/build'
[96/99] Linking C executable stm32f103xb_if.elf
#> Pre-build script start
#> Getting git SHA
#> Checking for local changes
#> Keeping git version file since it didn't need to change
#> Pre-build script completed written ../../../source/daplink/version_git.h
Memory region         Used Size  Region Size  %age Used
          m_text:         78 KB        78 KB    100.00%
        m_cfgrom:           9 B         1 KB      0.88%
          m_data:       12000 B      20224 B     59.34%
        m_cfgram:         142 B        256 B     55.47%
[99/99] Running utility command for stm32f103xb_if_binaries
build/stm32f103xb_if_crc
board_id None
family_id None
bin_offset None
Start 0x800c000, Length 0x13c00, CRC32 0x2e956e51
root INFO       Built stm32f103xb_if with the status: no errors
Traceback (most recent call last):
  File "/home/cd/usr/local/test/venv-37-zephyr/bin/progen", line 8, in <module>
    sys.exit(main())
  File "/home/cd/usr/local/test/venv-37-zephyr/lib/python3.7/site-packages/project_generator/__main__.py", line 62, in main
    return args.func(args)
  File "/home/cd/usr/local/test/venv-37-zephyr/lib/python3.7/site-packages/project_generator/commands/generate.py", line 65, in run
    build_failed, export_failed = r.get(timeout=20.0)
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 653, in get
    raise TimeoutError
multiprocessing.context.TimeoutError

(venv-37-zephyr) ls -al projectfiles/cmake_gcc_arm/stm32f103xb_if/build/*.hex
-rw-r--r--  1 cd  cd  222528 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if_crc.hex
-rw-r--r--  1 cd  cd  227627 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if.hex
(venv-37-zephyr) ls -al projectfiles/cmake_gcc_arm/stm32f103xb_if/build/*.bin
-rw-r--r--  1 cd  cd  113664 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if_crc_legacy_0x5000.bin
-rw-r--r--  1 cd  cd   80896 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if_crc_legacy_0x8000.bin
-rw-r--r--  1 cd  cd   80896 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if_crc.bin
-rwxr-xr-x  1 cd  cd   80896 Dec 17 20:22 projectfiles/cmake_gcc_arm/stm32f103xb_if/build/stm32f103xb_if.bin
(venv-37-zephyr) USE_NINJA=1 progen generate -t cmake_gcc_arm -p stm32f103xb_bl -b    
progen.generate INFO    Generating cmake_gcc_arm for stm32f103xb_bl
-- The C compiler identification is GNU 9.3.1
-- The CXX compiler identification is GNU 9.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/gcc-arm-embedded/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cd/cederom/work/CeDeROM/lab/embedded/arm/mbed/DAPLink/mbrossard-daplink.git/projectfiles/cmake_gcc_arm/stm32f103xb_bl/build
ninja: Entering directory `projectfiles/cmake_gcc_arm/stm32f103xb_bl/build'
[55/58] Linking C executable stm32f103xb_bl.elf
#> Pre-build script start
#> Getting git SHA
#> Checking for local changes
#> Keeping git version file since it didn't need to change
#> Pre-build script completed written ../../../source/daplink/version_git.h
Memory region         Used Size  Region Size  %age Used
    m_interrupts:          1 KB         1 KB    100.00%
          m_text:         46 KB        46 KB    100.00%
        m_cfgrom:          0 GB         1 KB      0.00%
          m_data:        8264 B      20224 B     40.86%
        m_cfgram:         142 B        256 B     55.47%
[58/58] Running utility command for stm32f103xb_bl_binaries
build/stm32f103xb_bl_crc
board_id None
family_id None
bin_offset None
Start 0x8000000, Length 0xbc00, CRC32 0xc65ca4e5
root INFO       Built stm32f103xb_bl with the status: no errors
  • Some python warnings from progen when using cmake build but the firmware is created :-)

Testing

  • The sam3u2c_mkit_dk_dongle_nrf5x_if did not work on two nRF52840PDK that I have. I have only one nRF52DK left and I am using it for work so I cannot risk sorry (well I could not resist and flashed the nRF52DK too and the interface did not boot do I had to revert to JLINK). Maybe a bootlader update is necessary?
  • I have some spare STM32 boards (MB1180revC, Nucleo-F429ZI, MB1136revC, MB1134 A-01, etc), but here firmware/bootloader upgrade seems a bit different and I never worked with them over DAPLink, if there are any instructions on how to convert ST-LINK to DAPLink please share :-)

- Skipping 0255, which was allocated to the initial DAPLink release for micro:bit v2.
@mbrossard
Copy link
Contributor Author

Based on your feedback I made a change (in commit c517c31 on my development branch) to switch those shell script to python with #!/usr/bin/env python.

You probably want to start with boards that either have a BOOT ROM loader (like LPC11U35) or have SWD headers for both target and probe.

@mbrossard
Copy link
Contributor Author

I was able to test the stm32f103xb_bl, see it start up and have the MAINTENANCE drive appear.

@mbrossard
Copy link
Contributor Author

I re-ordered the commits to pull forward the changes to existing code first (similar to #701), and then have the additions (CMSIS-RTOS2 and GCC startup for HICs, linker scripts), all of this rebased on latest master.

I am interested to know what works and what does not (and if possible why or even better with a patch), including regressions with armcc.

@Ashleyvk
Copy link

Hi,
I was able to compile stm32f103xb_if in Windows as per the instructions provided. I customized the hic_hal files for a new hic controller stm32f373cc. When I provided the command,
progen generate -p stm32f373cc_if -t make_gcc_arm
I got an error message as:
RuntimeError: Target: stm32f373cc not found, Please add the target to https://github.com/project-generator/project_generator_definitions
In the project generator definitions folder, I've added a yaml file for the new board. The board was added to projects.yaml file too.
Any suggestions on what can be done?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 22, 2021

Any suggestions on what can be done?

Please send a pull request to add the progen definition, I can release a new patch.

@mathias-arm
Copy link
Collaborator

Any suggestions on what can be done?

@Ashleyvk: I assume you have created a record file based on records/hic_hal/stm32f103xb.yaml replacing the common > target value to stm32f373cc. You can also try changing that value instead to cortex-m4.

@mbrossard
Copy link
Contributor Author

Thanks to the new release of project-generator by @0xc0170, I think we are close to merging this PR (into an experimental branch). Please have a look at the build instructions added in [8c0d175].

@Ashleyvk
Copy link

Ashleyvk commented Jan 26, 2021

I was able to compile the files for the new HIC stm32f373cc, but once the device is connected after programming the controller, I'm getting the error as USB device not recognized. I'm using STM32CubeProgrammer for programming the controller. Any suggestions on what changes to be made?

@mathias-arm mathias-arm merged commit f2b27a6 into ARMmbed:experimental_compilers Jan 27, 2021
@mbrossard
Copy link
Contributor Author

This PR is now merged into experimental_compilers. The discussion will continue in #770.

@Ashleyvk: you might want to start a draft pull request (based on and to experimental_compilers), an issue or a discussion specifically for adding support for a STM32F373CC HIC. It seems @BibyThm is also interested (#768). If you don't share the repository with your changes, it severely limits the ability to help you (but sharing does not guarantee a response). Adding a HIC is not a trivial matter. Based on my limited experience:

  • Start with porting the bootloader (and check for instance that it does not crash).
  • It helps a lot if you can also debug the HIC while running DAPLink (bootloader and interface).

@mbrossard mbrossard mentioned this pull request Jan 27, 2021
This was referenced Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants