Topic: creating a factory.bin for stm32l452

Hello!

I am trying to creating the factory.bin for stm32l452 using the .config file given in the /examples directory. I see that in the hal directory file- stm32l4.c, stm32l4xx_hal.h file is required. This file follows more dependencies which I have included. However, I get the following error when I run the make command.

make clean && make
/bin/sh: line 1: test: 0x200: integer expression expected
/bin/sh: line 1: test: 0x200: integer expression expected
/bin/sh: line 1: test: 0x200: integer expression expected
/bin/sh: line 1: test: 0x200: integer expression expected
/bin/sh: line 1: test: 0x200: integer expression expected
\t[CC-ARM] hal/stm32l4.o
\t[CC-ARM] src/string.o
\t[CC-ARM] src/image.o
\t[CC-ARM] src/libwolfboot.o
\t[CC-ARM] src/keystore.o
\t[CC-ARM] src/loader.o
\t[CC-ARM] src/boot_arm.o
make: *** No rule to make target '/home/ghost/STM32Cube/Repository/STM32Cube_FW_L4_V1.17.0/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.o', needed by 'wolfboot.elf'.  Stop.

I am not sure how to correct this error. I know that the file- stm32l4xx_hal_flash needs to be included as well but when i include it in the hal or src directory, the error remains. Please let me know what I can do fix this.

Thank you!

Share

Re: creating a factory.bin for stm32l452

Hi akuraparthy,

The L4 is our only STM32 port that requires drivers from ST. Please download the STM32L4xx_HAL driver from STM and point the STM32CUBE variable in your config to the path, i.e.:

STM32CUBE=/path/to/stm32-cube/in/your/system

Hope this helps.

Thanks,

--
Daniele - wolfSSL

Share

3 (edited by akuraparthy 2024-02-29 15:49:58)

Re: creating a factory.bin for stm32l452

Hello Daniel,

Thank you for your reply! This is my .config file now with the STM32CUBE variable pointing to the path of my STM32L4xx_HAL driver:
TARGET=stm32l4
SIGN=ECC256
HASH=SHA256
DEBUG?=0
VTOR?=1
CORTEX_M0?=0
NO_ASM?=0
EXT_FLASH?=0
SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE=1
WOLFBOOT_VERSION?=0
V?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0
IMAGE_HEADER_SIZE?=0x200
STM32CUBE?=$(HOME)/Documents/wolfboot4/stm32l4xx_hal_driver-master
.....
I still see this error: /bin/sh: line 1: test: 0x200: integer expression expected
\t[CC-ARM] hal/stm32l4.o
hal/stm32l4.c:24:10: fatal error: stm32l4xx_hal.h: No such file or directory
   24 | #include "stm32l4xx_hal.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:350: hal/stm32l4.o] Error 1

May I know what I am doing wrong here?
Along with placing the path in the config file, am I to copy all the inc files and src files into the hal directory?

Share

Re: creating a factory.bin for stm32l452

I'm wondering if the include paths are correct and match your current directory structure.

Wolfboot will be looking for that file (and other stm32l4xx_hal*.h) in one of the following:

      $(STM32CUBE)/Drivers/STM32L4xx_HAL_Driver/Inc/
      $(STM32CUBE)/Drivers/BSP/STM32L4xx_Nucleo_144/
      $(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32L4xx/Include/
      $(STM32CUBE)/Drivers/CMSIS/Include/

Share

Re: creating a factory.bin for stm32l452

Hello Daniel,

Thank you so much for your responses!

I have included the correct path in the .config file now but I see this error: \t[CC-ARM] hal/stm32l4.o
In file included from /home/ghost/Documents/wolfboot4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_def.h:29,
                 from /home/ghost/Documents/wolfboot4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash.h:27,
                 from hal/stm32l4xx_hal_conf.h:29,
                 from /home/ghost/Documents/wolfboot4/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal.h:29,
                 from hal/stm32l4.c:24:
/home/ghost/Documents/wolfboot4/Drivers/CMSIS/Device/ST/STM32L4xx/Include/stm32l4xx.h:174:3: error: #error "Please select first the target STM32L4xx device used in your application (in stm32l4xx.h file)"
  174 |  #error "Please select first the target STM32L4xx device used in your application (in stm32l4xx.h file)"


i realise that this means that the correct file- stm32l452.h is not being included properly even though I am define the macro in the stm32l4xx.h file:
#if !defined (STM32L412xx) && !defined (STM32L422xx) && \
    !defined (STM32L431xx) && !defined (STM32L432xx) && !defined (STM32L433xx) && !defined (STM32L442xx) && !defined (STM32L443xx) && \
    !defined (STM32L451xx) && !defined (STM32L452xx) && !defined (STM32L462xx) && \
    !defined (STM32L471xx) && !defined (STM32L475xx) && !defined (STM32L476xx) && !defined (STM32L485xx) && !defined (STM32L486xx) && \
    !defined (STM32L496xx) && !defined (STM32L4A6xx) && \
    !defined (STM32L4P5xx) && !defined (STM32L4Q5xx) && \
    !defined (STM32L4R5xx) && !defined (STM32L4R7xx) && !defined (STM32L4R9xx) && !defined (STM32L4S5xx) && !defined (STM32L4S7xx) && !defined (STM32L4S9xx)
  /* #define STM32L412xx */   /*!< STM32L412xx Devices */
  /* #define STM32L422xx */   /*!< STM32L422xx Devices */
  /* #define STM32L431xx */   /*!< STM32L431xx Devices */
  /* #define STM32L432xx */   /*!< STM32L432xx Devices */
  /* #define STM32L433xx */   /*!< STM32L433xx Devices */
  /* #define STM32L442xx */   /*!< STM32L442xx Devices */
  /* #define STM32L443xx */   /*!< STM32L443xx Devices */
  /* #define STM32L451xx */   /*!< STM32L451xx Devices */
   #define STM32L452xx        /*!< STM32L452xx Devices */
  /* #define STM32L462xx */   /*!< STM32L462xx Devices */
  /* #define STM32L471xx */   /*!< STM32L471xx Devices */
  /* #define STM32L475xx */   /*!< STM32L475xx Devices */
  /* #define STM32L476xx */   /*!< STM32L476xx Devices */
  /* #define STM32L485xx */   /*!< STM32L485xx Devices */
  /* #define STM32L486xx */   /*!< STM32L486xx Devices */
  /* #define STM32L496xx */   /*!< STM32L496xx Devices */
  /* #define STM32L4A6xx */   /*!< STM32L4A6xx Devices */
  /* #define STM32L4P5xx */   /*!< STM32L4Q5xx Devices */
  /* #define STM32L4R5xx */   /*!< STM32L4R5xx Devices */
  /* #define STM32L4R7xx */   /*!< STM32L4R7xx Devices */
  /* #define STM32L4R9xx */   /*!< STM32L4R9xx Devices */
  /* #define STM32L4S5xx */   /*!< STM32L4S5xx Devices */
  /* #define STM32L4S7xx */   /*!< STM32L4S7xx Devices */
  /* #define STM32L4S9xx */   /*!< STM32L4S9xx Devices */
#endif


could you guide me as to where to define this macro?

Share

Re: creating a factory.bin for stm32l452

This should be automatically included in your build (arch.mk around line 107):

    CFLAGS+=-DSTM32L4A6xx -DUSE_HAL_DRIVER -Isrc -Ihal 

This code has been tested with STM32L4A6, but you can change that to match your model

Share