diff --git a/.github/workflows/real-time-cpp.yml b/.github/workflows/real-time-cpp.yml
index ed0990af9..b2590f68e 100644
--- a/.github/workflows/real-time-cpp.yml
+++ b/.github/workflows/real-time-cpp.yml
@@ -102,19 +102,19 @@ jobs:
working-directory: ./
- name: install-osx-cross-homebrew-avr
run: |
- echo 'Tap osx-cross/homebrew-avr on MacOS via brew'
+ echo 'Tap, trust and install osx-cross/avr on MacOS via brew'
echo ""
- echo 'Install osx-cross/homebrew-avr on MacOS via brew'
cd ${{ runner.workspace }}/homebrew-avr
brew tap osx-cross/avr
- brew install avr-gcc@12
+ brew trust aws/tap azure/bicep osx-cross/avr
+ brew install osx-cross/avr/avr-gcc@15
working-directory: ./
- name: target-avr-macos-${{ matrix.suite }}
run: |
echo query the GNUmake version
make --version
- echo Add the brew-installed-avr-gcc@12 path
- PATH="/opt/homebrew/opt/avr-gcc@12/bin:$PATH"
+ echo Add the brew-installed-avr-gcc@15 path
+ PATH="/opt/homebrew/opt/avr-gcc@15/bin:$PATH"
echo ""
echo Query the avr-gcc version
avr-g++ -v
diff --git a/code_snippets/readme.md b/code_snippets/readme.md
index b78b38520..59636ca15 100644
--- a/code_snippets/readme.md
+++ b/code_snippets/readme.md
@@ -10,12 +10,10 @@ Real-Time-C++ - Code Snippets
-These are the code snippets from the chapters of the book
-C.M. Kormanyos,
-[Real-Time C++](https://www.springer.com/de/book/9783662629956):
-Efficient Object-Oriented
-and Template Microcontroller Programming, Fourth Edition
-(Springer, Heidelberg, 2021) ISBN 9783662629956.
+These are the code snippets from the chapters
+of the book C.M. Kormanyos, _Real-Time_ _C++:_ _Efficient_ _Object-Oriented_
+_and_ _Template_ _Microcontroller_ _Programming_, _4_$^{th}$ _Edition_
+and are made available for educational and exploratory use.
## Summary of the Code Snippets
diff --git a/examples/chapter02_02/readme.md b/examples/chapter02_02/readme.md
index d7444b134..d018c24c6 100644
--- a/examples/chapter02_02/readme.md
+++ b/examples/chapter02_02/readme.md
@@ -3,7 +3,7 @@
## The LED program
-
+
@@ -160,7 +160,7 @@ such as:
## Try it at _godbolt_
-Use the following [short link](https://godbolt.org/z/v5f45fMqq)
+Use the following [short link](https://godbolt.org/z/zbcof9E94)
to [godbolt](https://godbolt.org) in order to further explore this program.
In the afore-mentioned link, the file [`led.cpp`](./led.cpp) is,
@@ -171,7 +171,7 @@ but not executed because there is no target hardware available.
### On the Metal: _Clear_ and _Set_ Bit
Consider the assembly output near the bottom of the page in the right-side tab
-of the [short link](https://godbolt.org/z/v5f45fMqq)
+of the [short link](https://godbolt.org/z/zbcof9E94)
to [godbolt](https://godbolt.org). Upon close investigation,
the bit-_clear_ and bit-_set_ opcodes (`cbi` and `sbi`)
can be recognized.
diff --git a/examples/chapter03_02/readme.md b/examples/chapter03_02/readme.md
index ac05ff2ac..2ee66156c 100644
--- a/examples/chapter03_02/readme.md
+++ b/examples/chapter03_02/readme.md
@@ -3,7 +3,7 @@
## Integer Types Having Fixed Widths and Prime Numbers
-
+
@@ -89,7 +89,7 @@ A nifty little PC-based sieving program from the code snippets area helps to
[explore prime numbers](../../code_snippets/chapter03/chapter03_02-002a_explore_prime_numbers.cpp).
This code can be run in its entirety at the following
-[short link](https://godbolt.org/z/dPbM7v4ff) to [godbolt](https://godbolt.org).
+[short link](https://godbolt.org/z/Pa3WbG8h6) to [godbolt](https://godbolt.org).
## Prime Counting Function
diff --git a/examples/chapter06_01/readme.md b/examples/chapter06_01/readme.md
index c159bd33d..d6f4fdf6e 100644
--- a/examples/chapter06_01/readme.md
+++ b/examples/chapter06_01/readme.md
@@ -3,7 +3,7 @@
## A CRC Benchmark
-
+
@@ -91,7 +91,7 @@ The expected result of the CRC-32/MPEG-2 of these
data bytes is `0x0376'E6E7`.
This code can be run in its entirety at the following
-[short link](https://godbolt.org/z/ssTK8TjWj) to [godbolt](https://godbolt.org).
+[short link](https://godbolt.org/z/vvobo4Pnq) to [godbolt](https://godbolt.org).
The application benchmark task `app::benchmark::task_func`
computes the CRC-32/MPEG-2. The computation is run to completion
diff --git a/examples/chapter10_08/readme.md b/examples/chapter10_08/readme.md
index 561157a86..5d884fd32 100644
--- a/examples/chapter10_08/readme.md
+++ b/examples/chapter10_08/readme.md
@@ -3,7 +3,7 @@
## External SPI RAM and Computing 10,001 Digits of Pi
-
+
@@ -66,7 +66,7 @@ A similar implementation of the Pi Spigot program has been setup
at [godbolt](https://godbolt.org), where it can be compiled and executed.
This setup computes $10,001$ decimal digits of $\pi$.
-Use the following [short link](https://godbolt.org/z/EMx88ocxn)
+Use the following [short link](https://godbolt.org/z/cr7MxKsK3)
to further explore this program.
## 8-Bit MCU Adaptions
diff --git a/examples/chapter16_08/images/circuit16_08.png b/examples/chapter16_08/images/circuit16_08.png
new file mode 100644
index 000000000..16e4d516d
Binary files /dev/null and b/examples/chapter16_08/images/circuit16_08.png differ
diff --git a/examples/chapter16_08/readme.md b/examples/chapter16_08/readme.md
index e7ca3f4cf..ddcf18b1c 100644
--- a/examples/chapter16_08/readme.md
+++ b/examples/chapter16_08/readme.md
@@ -1,4 +1,5 @@
# Example Chapter16_08 (advanced level)
+
## Generate and Display 128-bit Random Prime Numbers
This advanced example uses a self-made pseudo-random electronic
@@ -34,7 +35,7 @@ from Newhaven Display International. The display
is 40 characters in width by 4 lines and is, in fact,
controlled as two individual displays packed together.
-The realease version of this software is intended to run on our target
+The release version of this software is intended to run on our target
with the 8-bit microcontroller, as shown below.
On this system, it takes approximately $15~\text{s}$ on average
to find each single new pseudo-random 128-bit prime.
@@ -51,10 +52,10 @@ project uses
[Boost.Multiprecision](https://www.boost.org/doc/libs/1_82_0/libs/multiprecision/doc/html/index.html)
for its 128-bit integer representation and independent primality testing.
-This advanced example's software running on an 8-bit micrcocontroller
+This advanced example's software running on an 8-bit microcontroller
exhibits a fascinating combination of elementary electronics,
real-time C++ object-oriented and template programming,
-and the inate elegance and beauty of pure mathematics.
+and the innate elegance and beauty of pure mathematics.
## Hardware Setup
@@ -71,7 +72,7 @@ of the breadboard. The $12~\text{V}$ supply (center left) stems from a classic L
voltage regulator, from which TTL $+5~\text{V}$ (upper left) is also derived for
the MCU and logic power rail.
-
+
In this particular image,
the system has accumulated a few hundred pseudo-random prime
@@ -83,7 +84,7 @@ with the prime number theorem.
The electronic subcircuit used for creating the random digitized noise
is sketched below.
-
+
The oscilloscope image below shows a small snapshot
of the random digitized noise from this circuit.
@@ -91,13 +92,12 @@ The square-wave-like pulses result from digitizing the random signal
above/below $0~\text{V}$. This is done with an op-amp and rudimentary logic,
as shown in the circuit.
-
+
## Deep Connection to the Prime Number Theorem
Recall the prime counting function
-previously encountered in Example Chapter03_02
-[here](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter03_02#prime-counting-function).
+previously encountered in Example [Chapter03_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter03_02#prime-counting-function).
The prime number theorem known from mathematical number theory
postulates that the prime counting function $\pi(x)$ for large $x$
asymptotically and approximately approaches
diff --git a/examples/chapter17_03/readme.md b/examples/chapter17_03/readme.md
index 77936b4ae..862a7ac4e 100644
--- a/examples/chapter17_03/readme.md
+++ b/examples/chapter17_03/readme.md
@@ -1,4 +1,5 @@
# Example Chapter17_03
+
## Traditional C Language Code in a Modern C++ Project
Example chapter17_03 depicts some methods that potentially allow
@@ -61,13 +62,12 @@ void Crc08_Finalize (Crc08_Context_Type* Crc_Context);
On top of the existing C-language CRC library we have built a skinny
object-oriented C++ wrapper class architecture that
allows the CRC objects to be used effectively in a
-modern C++ envorinment. The application benchmark task,
+modern C++ environment. The application benchmark task,
for instance, tests all four CRC functions and compares
the results with their expected values. As mentioned in
-, the standard
+[Example chapter06_01](../chapter06_01), the standard
CRC test involves the result of performing the CRC on the
-bytes of the ACII digits
-
.
+bytes of the ASCII digits $1$ through $9$.
The application task `app::crc::task_func()` is shown below.
diff --git a/examples/chapter17_03a/readme.md b/examples/chapter17_03a/readme.md
index cfaebff61..be448719e 100644
--- a/examples/chapter17_03a/readme.md
+++ b/examples/chapter17_03a/readme.md
@@ -1,4 +1,5 @@
# Example Chapter17_03a
+
## Traditional C-Language in Modern C++, Using Time Slices
Example chapter17_03a is almost identical with
@@ -105,7 +106,7 @@ void app::crc::task_func()
// Finalize this CRC object.
app_crc_checksums[app_crc_object_index]->finalize();
- // Increment to othe next CRC object in the list.
+ // Increment to the next CRC object in the list.
++app_crc_object_index;
if(app_crc_object_index >= app_crc_checksums.size())
diff --git a/examples/readme.md b/examples/readme.md
index b7a22cd1e..0089663f6 100644
--- a/examples/readme.md
+++ b/examples/readme.md
@@ -5,16 +5,13 @@
-
+
-These examples are motivated by the book
-C.M. Kormanyos,
-[Real-Time C++](https://www.springer.com/de/book/9783662629956):
-Efficient Object-Oriented
-and Template Microcontroller Programming, Fourth Edition
-(Springer, Heidelberg, 2021) ISBN 9783662629956.
+These examples are motivated by the book C.M. Kormanyos, _Real-Time_ _C++:_
+_Efficient_ _Object-Oriented_ _and_ _Template_ _Microcontroller_ _Programming_, _4_$^{th}$ _Edition_
+and are made available for educational and exploratory use.
The first couple of example projects can use the ARDUINO board directly
and non-modified. Examples from the later chapters in the book do, however,
@@ -140,11 +137,11 @@ in each individual example directory.
## Try it at _godbolt_
-
+
-Use this [short link](https://godbolt.org/z/fxWzb6h6f)
+Use this [short link](https://godbolt.org/z/zbcof9E94)
to [godbolt](https://godbolt.org) in order to further explore
Example [chapter02_02](https://github.com/ckormanyos/real-time-cpp/tree/master/examples/chapter02_02)
(the LED program). In the link, the main source file of the example
diff --git a/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S b/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S
index 7657d6dc8..37249e38e 100644
--- a/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S
+++ b/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S
@@ -2,56 +2,58 @@
.global coprocessor_bin
coprocessor_bin:
.byte 0x6F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00
- .byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0xC1, 0x4B, 0x6F, 0x00, 0xC0, 0x28, 0x41, 0x11, 0x06, 0xC6
- .byte 0x31, 0x2A, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0xB7, 0x16, 0x00, 0x50, 0x03, 0xA7, 0xC6, 0x09
- .byte 0xB7, 0x17, 0x00, 0x50, 0x93, 0x87, 0xC7, 0x0B, 0x3A, 0x95, 0x63, 0x74, 0xF5, 0x00, 0x23, 0xAE
- .byte 0xA6, 0x08, 0x3A, 0x85, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00
- .byte 0x01, 0x00, 0xFD, 0xBF, 0x01, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x00, 0xFD, 0xBF, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x00, 0xFD, 0xBF, 0x01, 0x00, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x7D, 0x55, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x7D, 0x55, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00
- .byte 0x7D, 0x55, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80
- .byte 0x01, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00
- .byte 0x01, 0x11, 0x2E, 0xC2, 0x32, 0xC4, 0x36, 0xC6, 0x3A, 0xC8, 0x3E, 0xCA, 0x42, 0xCC, 0x46, 0xCE
- .byte 0x01, 0xA0, 0x00, 0x00, 0x41, 0x11, 0x01, 0x45, 0x06, 0xC6, 0x89, 0x28, 0x01, 0x45, 0xA9, 0x20
- .byte 0xB2, 0x40, 0x01, 0x45, 0x41, 0x01, 0x3D, 0xA0, 0x37, 0x15, 0x00, 0x50, 0x13, 0x05, 0xC5, 0x0B
- .byte 0x82, 0x80, 0x00, 0x00, 0x41, 0x11, 0x06, 0xC6, 0xC5, 0x3F, 0x83, 0x47, 0x05, 0x00, 0x81, 0xE7
- .byte 0x85, 0x47, 0x23, 0x00, 0xF5, 0x00, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0x01, 0x45, 0x81, 0x45
- .byte 0x82, 0x80, 0x00, 0x00, 0x37, 0x07, 0x0C, 0x60, 0x9D, 0x46, 0xBA, 0x87, 0x14, 0xC7, 0x13, 0x07
- .byte 0x10, 0x40, 0xB8, 0xD3, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x37, 0x37, 0x1D, 0x8F
- .byte 0xB7, 0x87, 0x00, 0x60, 0x13, 0x07, 0xA7, 0x12, 0x23, 0xAC, 0xE7, 0x0A, 0x23, 0xAE, 0x07, 0x08
- .byte 0xB7, 0x06, 0x00, 0x40, 0x23, 0xAA, 0xD7, 0x0A, 0xB7, 0x46, 0xD8, 0x50, 0x23, 0xAC, 0x07, 0x0A
- .byte 0x93, 0x86, 0x16, 0xAA, 0xB7, 0xF7, 0x01, 0x60, 0xF4, 0xD3, 0x23, 0xA4, 0x07, 0x04, 0x23, 0xA2
- .byte 0x07, 0x06, 0x82, 0x80, 0x01, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80
- .byte 0x01, 0x00, 0x00, 0x00, 0x13, 0x07, 0x80, 0x3E, 0xAE, 0x87, 0x63, 0x73, 0xB7, 0x00, 0xBA, 0x87
- .byte 0x23, 0x14, 0xF5, 0x00, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0xB1, 0x45, 0x79, 0xB5
- .byte 0x41, 0x11, 0x01, 0x45, 0x06, 0xC6, 0xB9, 0x3F, 0x37, 0x17, 0x00, 0x50, 0x13, 0x07, 0x07, 0x0C
- .byte 0xB7, 0x1E, 0x00, 0x50, 0xA9, 0x66, 0x37, 0x08, 0x00, 0xF8, 0x83, 0x57, 0x67, 0x00, 0x83, 0x55
- .byte 0x47, 0x00, 0x93, 0x8E, 0x8E, 0x01, 0x93, 0x86, 0x06, 0x40, 0x7D, 0x18, 0x05, 0x47, 0x01, 0x4E
- .byte 0x13, 0x05, 0x80, 0x3E, 0xB7, 0x08, 0x00, 0x08, 0x3A, 0x83, 0x63, 0x74, 0xE5, 0x00, 0x13, 0x03
- .byte 0x80, 0x3E, 0x42, 0x03, 0x11, 0x67, 0x13, 0x53, 0x03, 0x01, 0x6D, 0x07, 0x85, 0x07, 0xC2, 0x07
- .byte 0x90, 0x42, 0xC1, 0x83, 0x63, 0xE5, 0xF5, 0x02, 0x33, 0x66, 0x16, 0x01, 0x90, 0xC2, 0x7D, 0x17
- .byte 0x63, 0x8B, 0xA7, 0x00, 0x65, 0xF7, 0x05, 0x0E, 0x13, 0x77, 0xFE, 0x03, 0x06, 0x07, 0x76, 0x97
- .byte 0x03, 0x57, 0x07, 0x00, 0xD1, 0xB7, 0x9A, 0x85, 0x81, 0x47, 0x69, 0xFB, 0xED, 0xB7, 0x33, 0x76
- .byte 0x06, 0x01, 0x90, 0xC2, 0xE9, 0xBF, 0x01, 0x00, 0x37, 0x17, 0x00, 0x50, 0xB7, 0x17, 0x00, 0x50
- .byte 0x13, 0x07, 0x07, 0x0C, 0x93, 0x87, 0x87, 0x00, 0x1C, 0xC3, 0xA9, 0x67, 0x83, 0xA6, 0x07, 0x40
- .byte 0x37, 0x06, 0x00, 0xF8, 0x7D, 0x16, 0xF1, 0x8E, 0x23, 0xA0, 0xD7, 0x40, 0x03, 0xA5, 0x87, 0x4C
- .byte 0x37, 0x08, 0x08, 0x00, 0xBE, 0x86, 0x33, 0x65, 0x05, 0x01, 0x23, 0xA4, 0xA7, 0x4C, 0x83, 0xA5
- .byte 0x07, 0x40, 0x37, 0x05, 0x00, 0x08, 0x6D, 0x8E, 0x23, 0xA0, 0xC7, 0x40, 0x83, 0xA7, 0xC7, 0x40
- .byte 0x23, 0x22, 0x07, 0x00, 0x23, 0x14, 0x07, 0x00, 0xC9, 0x8F, 0x23, 0xA6, 0xF6, 0x40, 0x82, 0x80
- .byte 0x01, 0x00, 0x00, 0x00, 0x41, 0x11, 0x06, 0xC6, 0xB1, 0x3D, 0x39, 0x20, 0xB1, 0x28, 0x6F, 0xF0
- .byte 0x3F, 0xF1, 0xDD, 0x35, 0xFD, 0xBF, 0x00, 0x00, 0x37, 0x16, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50
- .byte 0x13, 0x06, 0x06, 0x0A, 0x13, 0x07, 0xC7, 0x09, 0x63, 0x0F, 0xE6, 0x00, 0xB7, 0x17, 0x00, 0x50
- .byte 0x19, 0x8E, 0x93, 0x87, 0xC7, 0x09, 0x3E, 0x96, 0x94, 0x43, 0x91, 0x07, 0x11, 0x07, 0x23, 0x2E
- .byte 0xD7, 0xFE, 0xE3, 0x1B, 0xF6, 0xFE, 0xB7, 0x17, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50, 0x93, 0x87
- .byte 0x07, 0x0A, 0x13, 0x07, 0xC7, 0x0C, 0x63, 0x87, 0xE7, 0x00, 0x23, 0xA0, 0x07, 0x00, 0x91, 0x07
- .byte 0xE3, 0x9D, 0xE7, 0xFE, 0x82, 0x80, 0x00, 0x00, 0x41, 0x11, 0x22, 0xC4, 0x26, 0xC2, 0x37, 0x14
- .byte 0x00, 0x50, 0xB7, 0x14, 0x00, 0x50, 0x06, 0xC6, 0x13, 0x04, 0xC4, 0x09, 0x93, 0x84, 0x84, 0x09
- .byte 0x63, 0x08, 0x94, 0x00, 0x83, 0x27, 0xC4, 0xFF, 0x71, 0x14, 0x82, 0x97, 0xE3, 0x1C, 0x94, 0xFE
+ .byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0xC1, 0x4B, 0x6F, 0x00, 0x80, 0x29, 0xB7, 0x16, 0x00, 0x50
+ .byte 0x03, 0xA7, 0xC6, 0x09, 0xB7, 0x17, 0x00, 0x50, 0x93, 0x87, 0xC7, 0x0B, 0x3A, 0x95, 0x63, 0x74
+ .byte 0xF5, 0x00, 0x23, 0xAE, 0xA6, 0x08, 0x3A, 0x85, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00
+ .byte 0x82, 0x80, 0x00, 0x00, 0x01, 0x11, 0x32, 0xC4, 0x36, 0xC6, 0x3A, 0xC8, 0x3E, 0xCA, 0x42, 0xCC
+ .byte 0x46, 0xCE, 0x7D, 0x55, 0x05, 0x61, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF
+ .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF
+ .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFD, 0xBF
+ .byte 0x00, 0x00, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x7D, 0x55, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x55, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7D, 0x55, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00
+ .byte 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x01, 0x11, 0x2E, 0xC2
+ .byte 0x32, 0xC4, 0x36, 0xC6, 0x3A, 0xC8, 0x3E, 0xCA, 0x42, 0xCC, 0x46, 0xCE, 0x01, 0xA0, 0x00, 0x00
+ .byte 0x41, 0x11, 0x01, 0x45, 0x06, 0xC6, 0x89, 0x28, 0x01, 0x45, 0xA9, 0x20, 0xB2, 0x40, 0x01, 0x45
+ .byte 0x41, 0x01, 0x3D, 0xA0, 0x37, 0x15, 0x00, 0x50, 0x13, 0x05, 0xC5, 0x0B, 0x82, 0x80, 0x00, 0x00
+ .byte 0x41, 0x11, 0x06, 0xC6, 0xC5, 0x3F, 0x83, 0x47, 0x05, 0x00, 0x81, 0xE7, 0x85, 0x47, 0x23, 0x00
+ .byte 0xF5, 0x00, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0x01, 0x45, 0x81, 0x45, 0x82, 0x80, 0x00, 0x00
+ .byte 0x37, 0x07, 0x0C, 0x60, 0x9D, 0x46, 0xBA, 0x87, 0x14, 0xC7, 0x13, 0x07, 0x10, 0x40, 0xB8, 0xD3
+ .byte 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0xB7, 0x37, 0x1D, 0x8F, 0x37, 0x87, 0x00, 0x60
+ .byte 0x93, 0x87, 0xA7, 0x12, 0x23, 0x2C, 0xF7, 0x0A, 0x23, 0x2E, 0x07, 0x08, 0xB7, 0x06, 0x00, 0x40
+ .byte 0x23, 0x2A, 0xD7, 0x0A, 0xB7, 0x46, 0xD8, 0x50, 0xB7, 0xF7, 0x01, 0x60, 0x23, 0x2C, 0x07, 0x0A
+ .byte 0x93, 0x86, 0x16, 0xAA, 0xF4, 0xD3, 0x23, 0xA4, 0x07, 0x04, 0x23, 0xA2, 0x07, 0x06, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00
+ .byte 0x13, 0x07, 0x80, 0x3E, 0xAE, 0x87, 0x63, 0x73, 0xB7, 0x00, 0xBA, 0x87, 0x23, 0x14, 0xF5, 0x00
+ .byte 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0xB1, 0x45, 0x9D, 0xBD, 0x41, 0x11, 0x01, 0x45
+ .byte 0x06, 0xC6, 0xB9, 0x3F, 0x37, 0x17, 0x00, 0x50, 0x13, 0x07, 0x07, 0x0C, 0xB7, 0x1E, 0x00, 0x50
+ .byte 0xA9, 0x66, 0x37, 0x08, 0x00, 0xF8, 0x83, 0x57, 0x67, 0x00, 0x83, 0x55, 0x47, 0x00, 0x93, 0x8E
+ .byte 0x8E, 0x01, 0x93, 0x86, 0x06, 0x40, 0x7D, 0x18, 0x05, 0x47, 0x01, 0x4E, 0x13, 0x05, 0x80, 0x3E
+ .byte 0xB7, 0x08, 0x00, 0x08, 0x3A, 0x83, 0x63, 0x74, 0xE5, 0x00, 0x13, 0x03, 0x80, 0x3E, 0x42, 0x03
+ .byte 0x11, 0x67, 0x13, 0x53, 0x03, 0x01, 0x6D, 0x07, 0x85, 0x07, 0xC2, 0x07, 0x90, 0x42, 0xC1, 0x83
+ .byte 0x63, 0xE5, 0xF5, 0x02, 0x33, 0x66, 0x16, 0x01, 0x90, 0xC2, 0x7D, 0x17, 0x63, 0x8B, 0xA7, 0x00
+ .byte 0x65, 0xF7, 0x05, 0x0E, 0x13, 0x77, 0xFE, 0x03, 0x06, 0x07, 0x76, 0x97, 0x03, 0x57, 0x07, 0x00
+ .byte 0xD1, 0xB7, 0x9A, 0x85, 0x81, 0x47, 0x69, 0xFB, 0xED, 0xB7, 0x33, 0x76, 0x06, 0x01, 0x90, 0xC2
+ .byte 0xE9, 0xBF, 0x00, 0x00, 0x37, 0x17, 0x00, 0x50, 0xB7, 0x16, 0x00, 0x50, 0xA9, 0x67, 0x13, 0x07
+ .byte 0x07, 0x0C, 0x93, 0x86, 0x86, 0x00, 0x14, 0xC3, 0x83, 0xA6, 0x07, 0x40, 0x37, 0x06, 0x00, 0xF8
+ .byte 0x7D, 0x16, 0xF1, 0x8E, 0x23, 0xA0, 0xD7, 0x40, 0x03, 0xA5, 0x87, 0x4C, 0x37, 0x08, 0x08, 0x00
+ .byte 0xBE, 0x86, 0x33, 0x65, 0x05, 0x01, 0x23, 0xA4, 0xA7, 0x4C, 0x83, 0xA5, 0x07, 0x40, 0x37, 0x05
+ .byte 0x00, 0x08, 0x6D, 0x8E, 0x23, 0xA0, 0xC7, 0x40, 0x83, 0xA7, 0xC7, 0x40, 0x23, 0x22, 0x07, 0x00
+ .byte 0x23, 0x14, 0x07, 0x00, 0xC9, 0x8F, 0x23, 0xA6, 0xF6, 0x40, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00
+ .byte 0x41, 0x11, 0x06, 0xC6, 0xB1, 0x3D, 0x39, 0x20, 0xB5, 0x20, 0x6F, 0xF0, 0x3F, 0xF1, 0xDD, 0x35
+ .byte 0xFD, 0xBF, 0x00, 0x00, 0xB7, 0x16, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50, 0x93, 0x86, 0x06, 0x0A
+ .byte 0x93, 0x05, 0xC7, 0x09, 0xB7, 0x17, 0x00, 0x50, 0x33, 0x85, 0xB6, 0x40, 0x13, 0x86, 0xC7, 0x09
+ .byte 0x2A, 0x96, 0x63, 0x8D, 0xB6, 0x00, 0x13, 0x07, 0xC7, 0x09, 0x93, 0x87, 0xC7, 0x09, 0x94, 0x43
+ .byte 0x91, 0x07, 0x11, 0x07, 0x23, 0x2E, 0xD7, 0xFE, 0xE3, 0x1B, 0xF6, 0xFE, 0xB7, 0x17, 0x00, 0x50
+ .byte 0x37, 0x17, 0x00, 0x50, 0x93, 0x86, 0x07, 0x0A, 0x13, 0x07, 0xC7, 0x0C, 0x63, 0x89, 0xE6, 0x00
+ .byte 0x93, 0x87, 0x07, 0x0A, 0x23, 0xA0, 0x07, 0x00, 0x91, 0x07, 0xE3, 0x9D, 0xE7, 0xFE, 0x82, 0x80
+ .byte 0x00, 0x00, 0x00, 0x00, 0x41, 0x11, 0x22, 0xC4, 0x26, 0xC2, 0x37, 0x14, 0x00, 0x50, 0xB7, 0x14
+ .byte 0x00, 0x50, 0x06, 0xC6, 0x93, 0x07, 0xC4, 0x09, 0x93, 0x84, 0x84, 0x09, 0x63, 0x8A, 0x97, 0x00
+ .byte 0x13, 0x04, 0xC4, 0x09, 0x83, 0x27, 0xC4, 0xFF, 0x71, 0x14, 0x82, 0x97, 0xE3, 0x1C, 0x94, 0xFE
.byte 0xB2, 0x40, 0x22, 0x44, 0x92, 0x44, 0x41, 0x01, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -255,10 +257,8 @@ coprocessor_bin:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
- .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB8, 0x01, 0x00, 0x50, 0xBC, 0x01, 0x00, 0x50
- .byte 0x9C, 0x01, 0x00, 0x50, 0xA4, 0x01, 0x00, 0x50, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00
+ .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0x01, 0x00, 0x50, 0xC8, 0x01, 0x00, 0x50
+ .byte 0xA8, 0x01, 0x00, 0x50, 0xB0, 0x01, 0x00, 0x50, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00
.byte 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00
.byte 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x10, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00
.byte 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00
@@ -266,4 +266,4 @@ coprocessor_bin:
.byte 0x26, 0x00, 0x28, 0x00, 0x2A, 0x00, 0x2C, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00
.byte 0x36, 0x00, 0x38, 0x00, 0x3A, 0x00, 0x3C, 0x00, 0x3E, 0x00, 0x42, 0x00, 0x44, 0x00, 0x46, 0x00
.byte 0x48, 0x00, 0x4A, 0x00, 0x4C, 0x00, 0x4E, 0x00, 0x50, 0x00, 0x52, 0x00, 0x54, 0x00, 0x56, 0x00
- .byte 0x59, 0x00, 0x5C, 0x00, 0x60, 0x00, 0x64, 0x00, 0x48, 0x02, 0x00, 0x50, 0xAC, 0x10, 0x00, 0x50
+ .byte 0x59, 0x00, 0x5C, 0x00, 0x60, 0x00, 0x64, 0x00, 0x54, 0x02, 0x00, 0x50, 0xAC, 0x10, 0x00, 0x50
diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk
index bce3b52d6..887eba1ba 100644
--- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk
+++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk
@@ -87,8 +87,8 @@ PYTHON := python
BIN2ASM_FLAGS := -s ".coprocessor" \
- -l 16 \
- -g coprocessor_bin
+ -l 16 \
+ -g coprocessor_bin
RULE_SPECIAL_MAKE_IMAGE_FILE_PART00 := $(ECHO) +++ creating binary $(APP).bin
diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py
index 90bf2a262..32c4b0be0 100644
--- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py
+++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py
@@ -9,12 +9,49 @@
# Date : 27.02.2025
#
# Description : convert a binary image to assembly file
+# 2026-01-15: Added path validation to ensure input/output
+# files are within allowed base directory
#
#####################################################################################
import argparse
+import sys
+import re
+from pathlib import Path
-def binary_to_assembly(input_file, output_file, section_name, symbol_name, bytes_per_line):
- with open(input_file, "rb") as f:
+def is_within_directory(path: Path, base: Path) -> bool:
+ try:
+ path_resolved = path.resolve(strict=False)
+ base_resolved = base.resolve(strict=False)
+ return base_resolved == path_resolved or base_resolved in path_resolved.parents
+ except Exception:
+ return False
+
+def validate_path(path_str: str, base: Path, must_exist: bool = False, allow_create_parent: bool = False) -> Path:
+ path = Path(path_str)
+ # If user provided a relative path, make it relative to cwd then resolve
+ try:
+ resolved = path.resolve(strict=must_exist)
+ except Exception:
+ # If must_exist is False, resolve with strict=False to avoid exceptions for non-existent files
+ resolved = path.resolve(strict=False)
+ if not is_within_directory(resolved, base):
+ raise ValueError(f"Path '{path_str}' is outside allowed base directory '{base}'")
+ if must_exist and not resolved.exists():
+ raise ValueError(f"Required path does not exist: '{resolved}'")
+ if allow_create_parent:
+ parent = resolved.parent
+ if not is_within_directory(parent, base):
+ raise ValueError(f"Parent directory '{parent}' is outside allowed base '{base}'")
+ return resolved
+
+def validate_names(section_name: str, symbol_name: str):
+ if not re.match(r'^[A-Za-z0-9_.-]+$', section_name):
+ raise ValueError(f"Invalid section name: '{section_name}'")
+ if not re.match(r'^[A-Za-z_]\w*$', symbol_name):
+ raise ValueError(f"Invalid symbol name: '{symbol_name}'")
+
+def binary_to_assembly(input_file: Path, output_file: Path, section_name: str, symbol_name: str, bytes_per_line: int):
+ with input_file.open("rb") as f:
data = f.read()
asm_lines = [
@@ -28,7 +65,9 @@ def binary_to_assembly(input_file, output_file, section_name, symbol_name, bytes
byte_list = ", ".join(f"0x{b:02X}" for b in chunk)
asm_lines.append(f" .byte {byte_list}")
- with open(output_file, "w") as f:
+ # Safe creation and write (parent path was validated before calling)
+ output_file.parent.mkdir(parents=True, exist_ok=True)
+ with output_file.open("w", newline="\n") as f:
f.write("\n".join(asm_lines) + "\n")
if __name__ == "__main__":
@@ -38,6 +77,21 @@ def binary_to_assembly(input_file, output_file, section_name, symbol_name, bytes
parser.add_argument("-s", "--section", required=True, help="Target section name")
parser.add_argument("-g", "--symbol", required=True, help="Global symbol name")
parser.add_argument("-l", "--length", type=int, required=True, help="Number of bytes per .byte line")
+ parser.add_argument("--root", required=False, default=".", help="Allowed base root directory (default: current working directory)")
args = parser.parse_args()
- binary_to_assembly(args.input, args.output, args.section, args.symbol, args.length)
+
+ if args.length <= 0 or args.length > 4096:
+ print("Error: --length must be between 1 and 4096", file=sys.stderr)
+ sys.exit(2)
+
+ base_dir = Path(args.root).resolve()
+ try:
+ input_path = validate_path(args.input, base_dir, must_exist=True)
+ output_path = validate_path(args.output, base_dir, must_exist=False, allow_create_parent=True)
+ validate_names(args.section, args.symbol)
+ except ValueError as e:
+ print(f"Error: {e}", file=sys.stderr)
+ sys.exit(2)
+
+ binary_to_assembly(input_path, output_path, args.section, args.symbol, args.length)