linux-sunxi / sunxi-tools

A collection of command line tools for ARM devices with Allwinner SoCs.
http://linux-sunxi.org/
GNU General Public License v2.0
579 stars 421 forks source link

Rework uart0-helloworld-sdboot to use SoC table #211

Open apritzel opened 2 months ago

apritzel commented 2 months ago

Over time the seemingly simple uart0-helloworld-sdboot program became a bit of a mess: new SoCs tend to mix and match various properties, and people adding support for them needed to find the right group to put them into. This lead to long if (soc_is_xxx() || soc_is_yyy() ...) chains, which are not only hardly readable, but made any changes quite error-prone.

This series reworks the whole design, by adding a SoC table (inspired by soc_info.c), where we hold various values for each SoC: among the SoC ID and its name things like the UART base address, the clock base, and the UART0 pins. This not only simplifies the whole code, but makes adding support for new SoCs a breeze: as a bonus the last three patches add support for the A83T, the A80 and the A523. And even though this table takes about 1KB of RAM (for all the 23 supported SoCs), the whole binary got actually much smaller:

   text    data     bss     dec     hex filename
   4207       0      24    4231    1087 uart0-helloworld-sdboot.elf (before)
   2441       0      20    2461     99d uart0-helloworld-sdboot.elf (after)

Please review, I split the patches up to help with that process.