Skip to content

vanvught/GD32F470Z-EVAL-board-Bootloader-TFTP

Repository files navigation

GitHub C++ Standard GitHub issues GitHub contributors GitHub Sponsors Main

PayPal.Me Donate

GD32F470ZK Bootloader TFTP

This bootloader will install your application by means of the TFTP protocol. There is no need to change your application code. Per default DHCP is used for obtaining the ip-address.

The bootloader is active during reset of the board:

Otherwise the bootloader will directly jump to your application. With the snippet:

    	// 8. Call the reset handler
    	const uint32_t* reset_p = (uint32_t *)(FLASH_BASE + OFFSET_UIMAGE + 4);
    	asm volatile ("bx %0;" : : "r"(*reset_p));

The bootloader can be installed with the tools supplied by GigaDevice -> http://www.gd32mcu.com/en/download/7?kw=GD32F4

The limitation for the firmware file to be uploaded is given by the RAM available. With the 256K RAM we have a firmware file size limit of 171K.

See also https://www.gd32-dmx.org/bootloader.html

File: spiflashinstall.h

# elif defined (BOARD_GD32F470Z_EVAL)
#  define OFFSET_UIMAGE		0x008000	// 32K
#  define FIRMWARE_MAX_SIZE (171 * 1024)	// 171K

There is 171KB flash starting at 0x08008000

The change to be made in your build configuration is in the file gd32f470zk_flash.ld .

MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08008000, LENGTH = 171K
  TCMSRAM (rw)    : ORIGIN = 0x10000000, LENGTH = 64K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 112K
  RAM1 (xrw)      : ORIGIN = 0x2001C000, LENGTH = 16K
  RAM2 (xrw)      : ORIGIN = 0x20020000, LENGTH = 64K
  RAMADD (xrw)    : ORIGIN = 0x20030000, LENGTH = 0K
  BKPSRAM (rw)    : ORIGIN = 0x40024000, LENGTH = 4K
}

The FLASH ORIGIN must match the OFFSET_UIMAGE from the bootloader file spiflashinstall.h

The code for the bootloader is a fork from https://github.com/vanvught/rpidmx512. In order to reduce the memory footprint, some functions are not available.