Skip to content

Commit 3e3f18c

Browse files
authored
Merge pull request #635 from ckormanyos/docs_and_syntax
2 parents 150a72a + 834aecc commit 3e3f18c

10 files changed

Lines changed: 146 additions & 124 deletions

File tree

readme.md

Lines changed: 90 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ In this way the project exhibits a high level of portability.
6666

6767
## Supported Targets in the Reference Application
6868

69-
The reference application supports the following targets:
69+
The reference application supports the following targets (in alpha-numeric order):
7070

7171
| Target name (as used in build command) | Target Description | *(breadboard) |
7272
| -------------------------------------- | ----------------------------------------------------------- | ------------- |
73-
| `avr` | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmega328P | X |
73+
| `am335x` | BeagleBone with Texas Instruments(R) AM335x ARM(R) A8 | |
7474
| `atmega2560` | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmega2560 | |
7575
| `atmega4809` | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmegax4809 | X |
76-
| `am335x` | BeagleBone with Texas Instruments(R) AM335x ARM(R) A8 | |
77-
| `bcm2835_raspi_b` | RaspberryPi(R) Zero with ARM1176-JZFS(TM) | |
76+
| `avr` (as used in the book) | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmega328P | X |
77+
| `bcm2835_raspi_b` | RaspberryPi(R) Zero with ARM1176-JZFS(TM) | X |
7878
| `Debug`/`Release` | PC on `Win*` via MSVC x64 compiler `Debug`/`Release` | |
7979
| `host` | PC/Workstation on `Win*`/`mingw64`/`*nix` via host compiler | |
8080
| `lpc11c24` | NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+ | |
@@ -359,17 +359,23 @@ any additional libraries for these projects
359359
(other than those that are ordinarily installed
360360
during the standard installation of ATMEL Studio).
361361

362-
## Target Details
362+
## Details on Selected Target
363363

364364
Target details including startup code and linker definition files can
365365
be found in the [ref_app/target](./ref_app/target) directory
366366
and its subdirectories. There are individual subdirectories for
367367
each supported target microcontroller system.
368368

369-
The MICROCHIP(R) [former ATMEL(R)] AVR(R) configuration
370-
called `target avr` runs
371-
on a classic ARDUINO(R) compatible board.
372-
The program toggles the yellow LED on `portb.5`.
369+
The ARM(R) A8 configuration (called `target am335x`) runs on the BeagleBone
370+
board (black edition). For the white edition, the CPU clock needs to be reduced
371+
from $900~\text{MHz}$ to something like $600~\text{MHz}$. This project creates a bare-metal program
372+
for the BeagleBone that runs independently from any kind of `*nix` distro on
373+
the board. Our program is designed to boot the BeagleBone from a raw binary file
374+
called _MLO_ stored on a FAT32 SDHC microcard. The binary file includes a
375+
special boot header comprised of two 32-bit integers. The program is loaded
376+
from SD-card into RAM memory and subsequently executed. When switching on
377+
the BeagleBone black, the boot button (S2) must be pressed while powering
378+
up the board. The program toggles the first user LED (LED1 on `port1.21`).
373379

374380
The MICROCHIP(R) [former ATMEL(R)] AVR(R) configuration
375381
called `target atmega2560` runs
@@ -389,70 +395,10 @@ on an ARDUINO(R) EVERY compatible board clocked
389395
with the internal resonator at $20~\text{MHz}$.
390396
The program toggles the yellow LED on `porte.2` (i.e., `D5`).
391397

392-
The Espressif (`target xtensa32`) port for NodeMCU ESP32
393-
uses a subset of the
394-
[Espressif SDK](https://github.com/espressif/esp-idf)
395-
to run the reference application.
396-
This somewhat unconventional implementation configures
397-
$1$ single OS task running exclusively on $1$ CPU core only.
398-
Additional reductions in code/memory size(s) have been accomplished
399-
via selective stubbing of library functions.
400-
401-
The Espressif (`target xtensa_esp32_s3`) port for NodeMCU ESP32-S3
402-
features a bare-metal startup _without_ using any of the SDK.
403-
The bare-metal startup was taken from the work of
404-
[Chalandi/Baremetal_esp32s3_nosdk](https://github.com/Chalandi/Baremetal_esp32s3_nosdk).
405-
The multicore system first boots core0 which subsequently
406-
starts up core1 and also starts up the RISC-V-ULP coprocessor core.
407-
Blinky runs in the standard `ref_app`
408-
on core0 toggling `port7` while an endless timer loop on core1
409-
toggles `port6`. These LED ports togle in near unison
410-
at the normal blinky feequency of $\frac{1}{2}~\text{Hz}$.
411-
The RISC-V-ULP coprocessor performs an LED dimming
412-
show on `port17` at a randomly chosen frequency
413-
that is asynchronous to the regular blinky show.
414-
Self-procured LEDs and resistors need to be fitted externally
415-
on the port pins in order to observe blinking and dimming
416-
on this particular board.
417-
418-
The NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+ configuration
419-
called `target lpc11c24` toggles the LED on `port0.8`.
420-
421-
The ARM(R) Cortex(R)-M3 configuration (called `target stm32f100`) runs on
422-
the STM32VL-DISCOVERY board commercially available from ST Microelectronics(R).
423-
The program toggles the blue LED on `portc.8`.
424-
425-
The second ARM(R) Cortex(R)-M3 configuration (called `target stm32l100c`)
426-
runs on the STM32L100-DISCOVERY board commercially available from
427-
ST Microelectronics(R). The program toggles the blue LED on `portc.8`.
428-
429-
The third ARM(R) Cortex(R)-M3 configuration (called `target stm32l152`)
430-
runs on the STM32L152C-DISCOVERY board commercially available from
431-
ST Microelectronics(R). The program toggles the blue LED on `portb.6`.
432-
433-
The first ARM(R) Cortex(R)-M4F configuration (called `target stm32f407`) runs on
434-
the STM32F4-DISCOVERY board commercially available from ST Microelectronics(R).
435-
The program toggles the blue LED on `portd.15`.
436-
437-
Another ARM(R) Cortex(R)-M4F configuration (called `target stm32f446`) runs on
438-
the STM32F446-NUCLEO-64 board commercially available from ST Microelectronics(R).
439-
The program toggles the green LED on `porta.5`.
440-
An Ozone debug file is supplied for this system for those interested.
441-
442-
The first ARM(R) Cortex(R)-M7 configuration (called `target stm32h7a3`) runs on
443-
the STM32H7A3-NUCLEO-144 board commercially available from ST Microelectronics(R).
444-
The program toggles the green LED on `portb.0`.
445-
446-
The ARM(R) A8 configuration (called `target am335x`) runs on the BeagleBone
447-
board (black edition). For the white edition, the CPU clock needs to be reduced
448-
from $900~\text{MHz}$ to something like $600~\text{MHz}$. This project creates a bare-metal program
449-
for the BeagleBone that runs independently from any kind of `*nix` distro on
450-
the board. Our program is designed to boot the BeagleBone from a raw binary file
451-
called _MLO_ stored on a FAT32 SDHC microcard. The binary file includes a
452-
special boot header comprised of two 32-bit integers. The program is loaded
453-
from SD-card into RAM memory and subsequently executed. When switching on
454-
the BeagleBone black, the boot button (S2) must be pressed while powering
455-
up the board. The program toggles the first user LED (LED1 on `port1.21`).
398+
The MICROCHIP(R) [former ATMEL(R)] AVR(R) configuration
399+
called `target avr` (as used in the book) runs
400+
on a classic ARDUINO(R) compatible board.
401+
The program toggles the yellow LED on `portb.5`.
456402

457403
The ARM(R) 1176-JZF-S configuration (called `target bcm2835_raspi_b`) runs on the
458404
RaspberryPi(R) Zero (PiZero) single core controller.
@@ -469,33 +415,65 @@ config.txt, all described on internet. A complete set of
469415
running the bare-metal reference application are included in this repo.
470416
The program toggles the GPIO status LED at GPIO index `0x47`.
471417

418+
The NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+ configuration
419+
called `target lpc11c24` toggles the LED on `port0.8`.
420+
421+
Target `nxp_imxrt1062` runs on the Teensy 4.0 board from Spark Fun.
422+
The orange user-LED is toggled.
423+
424+
The `riscvfe310` target utilizes the SiFive RISC-V FE310 SoC
425+
on Spark Fun's commercially available _Red_ _Thing_ _Plus_ Board.
426+
The blue LED on port `GPIO0.5` is toggled.
427+
472428
The `rpi_pico_rp2040` target configuration employs the
473429
RaspberryPi(R) Pico RP2040 with dual-core ARM(R) Cortex(R)-M0+
474430
clocked at $133~\text{MHz}$. The low-level startup boots through
475-
core0. Core0 then starts up core1 (via a specific protocol).
476-
Core1 subsequently carries out the blinky application,
477-
while core0 enters an endless, idle loop.
478-
Ozone debug files are supplied for this system for those interested.
479-
Reverse engineering of the complicated (and scantly documented)
480-
dual-core startup originated in and have been taken from (with many thanks)
481-
from the `Blinky_Pico_dual_core_nosdk`
482-
[repo](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk).
431+
core0 which then starts up core1 via specific protocol.
432+
Core1 carries out the blinky application while core0 enters an endless,
433+
idle loop. Ozone debug files are supplied for this system
434+
for those interested. Reverse engineering of the complicated
435+
and scantly documented dual-core startup originated in
436+
and have been taken (with many thanks) from the
437+
[`Chalandi/Blinky_Pico_dual_core_nosdk`](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk).
438+
repository.
483439

484440
The `rpi_pico2_rp2350` target configuration employs the
485441
RaspberryPi(R) Pico2 RP2350 with dual-core ARM(R) Cortex(R)-M33
486442
clocked at $150~\text{MHz}$. It has essentially the same boot
487443
structure as the `2040`. Similarly the dual-core startup was
488-
pioneered by the efforts revealed in the modernized `Blinky_Pico2_dual_core_nosdk`
489-
[repo](https://github.com/Chalandi/Blinky_Pico2_dual_core_nosdk).
444+
pioneered by the efforts revealed in the modernized
445+
[`Chalandi/Blinky_Pico2_dual_core_nosdk`](https://github.com/Chalandi/Blinky_Pico2_dual_core_nosdk).
446+
repository.
447+
448+
The ARM(R) Cortex(R)-M3 configuration (called `target stm32f100`) runs on
449+
the STM32VL-DISCOVERY board commercially available from ST Microelectronics(R).
450+
The program toggles the blue LED on `portc.8`.
451+
452+
The first ARM(R) Cortex(R)-M4F configuration (called `target stm32f407`) runs on
453+
the STM32F4-DISCOVERY board commercially available from ST Microelectronics(R).
454+
The program toggles the blue LED on `portd.15`.
455+
456+
Another ARM(R) Cortex(R)-M4F configuration (called `target stm32f446`) runs on
457+
the STM32F446-NUCLEO-64 board commercially available from ST Microelectronics(R).
458+
The program toggles the green LED on `porta.5`.
459+
An Ozone debug file is supplied for this system for those interested.
460+
461+
The first ARM(R) Cortex(R)-M7 configuration (called `target stm32h7a3`) runs on
462+
the STM32H7A3-NUCLEO-144 board commercially available from ST Microelectronics(R).
463+
The program toggles the green LED on `portb.0`.
464+
465+
The second ARM(R) Cortex(R)-M3 configuration (called `target stm32l100c`)
466+
runs on the STM32L100-DISCOVERY board commercially available from
467+
ST Microelectronics(R). The program toggles the blue LED on `portc.8`.
468+
469+
The third ARM(R) Cortex(R)-M3 configuration (called `target stm32l152`)
470+
runs on the STM32L152C-DISCOVERY board commercially available from
471+
ST Microelectronics(R). The program toggles the blue LED on `portb.6`.
490472

491473
The `target v850es_fx2` implementation uses a classic Renesas(R) V850es/Fx2 core.
492474
The upd703231 microcontroller derivative on an F-Line _Drive_ _It_
493475
starter kit is used.
494476

495-
The `riscvfe310` target utilizes the SiFive RISC-V FE310 SoC
496-
on Spark Fun's commercially available _Red_ _Thing_ _Plus_ Board.
497-
The blue LED on port `GPIO0.5` is toggled.
498-
499477
The adaption for `wch_ch32v307` runs on the WCH CH32v307 board.
500478
It uses the RISC-V CH32v307 microcontroller from
501479
Nanjing Qinheng Microelectronics Co., Ltd.
@@ -505,8 +483,31 @@ The similar adaption `wch_ch32v307_llvm` is essentially
505483
the same except it uses an LLVM RISC-V toolchain
506484
instead of GCC RISC-V.
507485

508-
Target `nxp_imxrt1062` runs on the Teensy 4.0 board from Spark Fun.
509-
The orange user-LED is toggled.
486+
The Espressif (`target xtensa_esp32_s3`) port for NodeMCU ESP32-S3
487+
features a bare-metal startup _without_ using any of the SDK.
488+
The bare-metal startup was taken from the work of
489+
[Chalandi/Baremetal_esp32s3_nosdk](https://github.com/Chalandi/Baremetal_esp32s3_nosdk).
490+
The multicore system first boots core0 which subsequently
491+
starts up core1 and also starts up the RISC-V-ULP coprocessor core.
492+
Blinky runs in the standard `ref_app`
493+
on core0 toggling `port7` while an endless timer loop on core1
494+
toggles `port6`. These LED ports togle in near unison
495+
at the normal blinky feequency of $\frac{1}{2}~\text{Hz}$.
496+
The RISC-V-ULP coprocessor performs an LED dimming
497+
show on `port17` at a randomly chosen frequency
498+
that is asynchronous to the regular blinky show.
499+
Self-procured LEDs and resistors need to be fitted externally
500+
on the port pins in order to observe blinking and dimming
501+
on this particular board.
502+
503+
The Espressif (`target xtensa32`) port for NodeMCU ESP32
504+
uses a subset of the
505+
[Espressif SDK](https://github.com/espressif/esp-idf)
506+
to run the reference application.
507+
This somewhat unconventional implementation configures
508+
$1$ single OS task running exclusively on $1$ CPU core only.
509+
Additional reductions in code/memory size(s) have been accomplished
510+
via selective stubbing of library functions.
510511

511512
For other compatible boards, feel free contact me directly or submit
512513
an issue requesting support for your desired target system.

ref_app/target/micros/xtensa_esp32_s3/startup/Std/StdLib.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@
2929

3030
extern "C" {
3131

32-
typedef signed long long DItype __attribute__((mode (DI)));
33-
typedef unsigned long long UDItype __attribute__((mode (DI)));
34-
typedef unsigned int USItype __attribute__((mode (SI)));
32+
using DItype = signed long long;
33+
using UDItype = unsigned long long;
34+
using USItype = unsigned int;
3535

36-
extern int __builtin_clzll(unsigned long long);
36+
extern auto __builtin_clzll(unsigned long long) -> int;
3737

38-
#define DWtype DItype
39-
#define UDWtype UDItype
40-
#define UWtype USItype
38+
using DWtype = DItype;
39+
using UDWtype = UDItype;
40+
using UWtype = USItype;
4141

42-
UDWtype __udivdi3 (UDWtype n, UDWtype d);
43-
UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp);
44-
UDWtype __umoddi3 (UDWtype u, UDWtype v);
42+
auto __udivdi3 (UDWtype n, UDWtype d) -> UDWtype;
43+
auto __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) -> UDWtype;
44+
auto __umoddi3 (UDWtype u, UDWtype v) -> UDWtype;
4545

46-
UDWtype __udivdi3 (UDWtype n, UDWtype d)
46+
auto __udivdi3 (UDWtype n, UDWtype d) -> UDWtype
4747
{
4848
return __udivmoddi4 (n, d, (UDWtype *) 0);
4949
}
5050

51-
UDWtype __umoddi3 (UDWtype u, UDWtype v)
51+
auto __umoddi3 (UDWtype u, UDWtype v) -> UDWtype
5252
{
5353
UDWtype w;
5454

@@ -57,7 +57,7 @@ UDWtype __umoddi3 (UDWtype u, UDWtype v)
5757
return w;
5858
}
5959

60-
UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
60+
auto __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) -> UDWtype
6161
{
6262
UDWtype q = 0, r = n, y = d;
6363
UWtype lz1, lz2, i, k;
@@ -136,7 +136,7 @@ UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp)
136136
#pragma GCC diagnostic ignored "-Wcast-align"
137137
#endif
138138

139-
void* memset(void* str, int c, size_t n)
139+
auto memset(void* str, int c, size_t n) -> void*
140140
{
141141
std::uint8_t* ptr { reinterpret_cast<std::uint8_t*>(str) };
142142

@@ -180,7 +180,7 @@ void* memset(void* str, int c, size_t n)
180180
return str;
181181
}
182182

183-
void* memcpy (void* dest, const void* src, size_t n)
183+
auto memcpy (void* dest, const void* src, size_t n) -> void*
184184
{
185185
std::uint8_t* d { reinterpret_cast<std::uint8_t*>(dest) };
186186
const std::uint8_t* s { reinterpret_cast<const uint8_t*>(src) };

ref_app/target/micros/xtensa_esp32_s3/startup/Std/core-isa.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
17

28
// Originally from (but slightly modified from):
39

ref_app/target/micros/xtensa_esp32_s3/startup/Std/ieee754-sf.S

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
/******************************************************************************************
2+
// Copyright Christopher Kormanyos 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
******************************************************************************************/
18

2-
// Originally from:
9+
// Originally from (but slightly modified from):
310

411
/* IEEE-754 single-precision functions for Xtensa
512
Copyright (C) 2006-2025 Free Software Foundation, Inc.
@@ -272,7 +279,8 @@ __addsf3:
272279

273280
/* Subtraction */
274281
__subsf3_aux:
275-
282+
.align 4
283+
276284
/* Handle NaNs and Infinities. (This code is placed before the
277285
start of the function just to keep it in range of the limited
278286
branch displacements.) */
@@ -438,7 +446,7 @@ __subsf3:
438446
movi a2, 0
439447
leaf_return
440448

441-
.Lsub_borrow:
449+
.Lsub_borrow:
442450
/* The subtraction has underflowed into the exponent field, so the
443451
value needs to be renormalized. Shift the mantissa left as
444452
needed to remove any leading zeros and adjust the exponent
@@ -502,12 +510,12 @@ __subsf3:
502510

503511
#ifdef L_mulsf3
504512

505-
/* Multiplication */
513+
/* Multiplication */
506514
#if !XCHAL_HAVE_MUL16 && !XCHAL_HAVE_MUL32 && !XCHAL_HAVE_MAC16
507515
#define XCHAL_NO_MUL 1
508516
#endif
509517

510-
.literal_position
518+
.literal_position
511519
__mulsf3_aux:
512520

513521
/* Handle unusual cases (zeros, subnormals, NaNs and Infinities).

ref_app/target/micros/xtensa_esp32_s3/startup/Std/lib1funcs.S

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
2-
// Originally from:
1+
/******************************************************************************************
2+
// Copyright Christopher Kormanyos 2025.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
******************************************************************************************/
8+
9+
// Originally from (but slightly modified from):
310

411
/* Assembly functions for the Xtensa version of libgcc1.
512
Copyright (C) 2001-2025 Free Software Foundation, Inc.

ref_app/target/micros/xtensa_esp32_s3/startup/boot.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
******************************************************************************************/
88

9-
/* Originally from: */
9+
/* Originally from (but slightly modified from): */
1010
/******************************************************************************************
1111
Filename : boot.S
1212

0 commit comments

Comments
 (0)