Skip to content

Latest commit

 

History

History
110 lines (76 loc) · 5.03 KB

README.md

File metadata and controls

110 lines (76 loc) · 5.03 KB

HC32F460 HAL

This document provides notes on the HAL for the HC32F460 MCU.

Adding support for a new board

The HC32F460 HAL is designed to be generic enough for any HC32F460-based board. Adding support for a new HC32F460-based board will require the following steps:

  1. Follow the usual instructions to add a new board to Marlin. (i.e., Add a pins file, edit boards.h and pins.h, etc.)
  2. Determine the flash size your board uses:
    • Examine the board's main processor. (Refer the naming key in hc32.ini.)
    • Extend the HC32F460C_common base env for 256K, or HC32F460E_common for 512K.
  3. Determine your board's application start address (see below)
  4. Set board_build.ld_args.flash_start to the app start address once you've found it. If your board doesn't use a bootloader, you may be able to use the "ICSP" header or DFU. This document will be updated once we have more information about flashing without a bootloader.

Finding the application start address

If the board contains a bootloader you'll need to find the application address. This is the address the bootloader jumps to after it's done. You can find this address in a few different ways:

1. Using log messages

If you're lucky, the bootloader may print the app start address on the serial output during boot. To check for this, use your favorite serial monitor to observe the serial output when you power on the board. Look for a message like "Jumping to 0xC000" or "GotoApp->addr=0xC000". This line would be printed before Marlin's "start" message.

Example:

[...]
version 1.2
sdio init success!
Disk init
Tips ------ None Firmware file
GotoApp->addr=0xC000

start
[...]

2. Using published source code

If the vendor has published Marlin source code that includes the bootloader, you can search the bootloader source code for the address. Begin your search with the following steps:

  1. Find the code that sets the vector table offset

The vector table offset is usually set using a line like this:

SCB->VTOR = ((uint32_t) APP_START_ADDRESS & SCB_VTOR_TBLOFF_Msk);

Just searching for SCB->VTOR should yield some results. From there, you just need to look at the value that's assigned to it. The example uses APP_START_ADDRESS.

Note

Some vendors publish incomplete source code. But they sometimes leave version control related files in the repo, which can contain previous version of files that were removed. Find these by including folders like .git or .svn in your search.

Note

The example is based on the Voxelab-64/Aquila_X2 which actually includes deleted files in its repo.

  1. Using a linker script

If the repository contains a linker script, look at the memory regions, specifically a region named FLASH or similar. The ORIGIN of that region will be the application start address.

Example:

MEMORY
{
    FLASH       (rx): ORIGIN = 0x0000C000, LENGTH = 512K
    OTP         (rx): ORIGIN = 0x03000C00, LENGTH = 1020
    RAM        (rwx): ORIGIN = 0x1FFF8000, LENGTH = 188K
    RET_RAM    (rwx): ORIGIN = 0x200F0000, LENGTH = 4K
}

Note

This example is based on Voxelab-64/Aquila_X2

Documentation on the HC32F460

Due to uncertain licensing (w/r/t STMicro), documentation for the HC32F460 is only available upon request. Documentation includes the following:

  • Datasheet, user manual, reference manual
  • Application notes for the DDL
  • DDL source code
  • IDE support packages (Keil, IAR, ...) including .svd files
  • Programming software
  • Emulator / debugger drivers
  • Development board documentation and schematics
  • Errata documents
  • (Limited) sales information
  • Full Voxelab firmware source code
  • Documents in Chinese or English (machine translated)

Contact me on Discord (@shadow578) if you need it.

Dependencies

This HAL depends on the following projects:

Credits

This HAL wouldn't be possible without the following projects: