Skip to content

Commit ba4e9ac

Browse files
authored
Merge pull request #88 from wnienhaus/use-new-binutils-gdb
Use new binutils gdb
2 parents 05fdeb3 + f85fc20 commit ba4e9ac

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

Diff for: .github/workflows/run_tests.yaml

+26-20
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,32 @@ jobs:
4040
test $(micropython -c 'print("test")') = "test"
4141
popd
4242
43-
- name: Build binutils-esp32ulp
44-
id: build_binutils
43+
- name: Fetch binutils-esp32ulp
44+
id: fetch_binutils
4545
run: |
46-
echo "Building binutils-esp32ulp"
47-
# building requires an older version of gcc
48-
sudo apt-get install -y gcc-7 g++-7
49-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
50-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
51-
git clone --depth 1 https://github.com/espressif/binutils-esp32ulp.git
52-
pushd binutils-esp32ulp
53-
git describe --always --tags
54-
./configure --target=esp32ulp-elf --prefix=$PWD/dist --disable-doc --disable-gdb --disable-libdecnumber --disable-readline --disable-sim
55-
echo "MAKEINFO = :" >> Makefile
56-
make
57-
make install-strip
58-
export PATH=$PATH:$PWD/dist/bin
59-
echo "bin_dir=$PWD/dist/bin" >> $GITHUB_OUTPUT
46+
echo "Fetching URL of pre-built esp32ulp-elf binaries"
47+
## URL to pre-built binaries is published in esp-idf
48+
IDFVER=v5.0.1
49+
curl -s \
50+
-o tools.json \
51+
https://raw.githubusercontent.com/espressif/esp-idf/$IDFVER/tools/tools.json
52+
URL=$(<tools.json jq -r '
53+
.tools[]
54+
| select(.name == "esp32ulp-elf").versions[]
55+
| select(.status == "recommended")
56+
| .["linux-amd64"]
57+
| .url
58+
// empty
59+
')
60+
61+
echo "Downloading esp32ulp-elf from $URL"
62+
curl -sL \
63+
-o /tmp/esp32ulp-elf.tar.gz \
64+
$URL
65+
tar xfvz /tmp/esp32ulp-elf.tar.gz esp32ulp-elf/bin
66+
export PATH=$PATH:$PWD/esp32ulp-elf/bin
67+
echo "bin_dir=$PWD/esp32ulp-elf/bin" >> $GITHUB_OUTPUT
6068
esp32ulp-elf-as --version | grep 'esp32ulp-elf' > /dev/null
61-
popd
6269
6370
###### Run tests ######
6471

@@ -73,15 +80,14 @@ jobs:
7380
id: compat_tests
7481
run: |
7582
export PATH=$PATH:${{ steps.build_micropython.outputs.bin_dir }}
76-
export PATH=$PATH:${{ steps.build_binutils.outputs.bin_dir }}
83+
export PATH=$PATH:${{ steps.fetch_binutils.outputs.bin_dir }}
7784
cd tests
7885
./01_compat_tests.sh
7986
8087
- name: Run compat tests with RTC macros
8188
id: compat_rtc_tests
8289
run: |
8390
export PATH=$PATH:${{ steps.build_micropython.outputs.bin_dir }}
84-
export PATH=$PATH:${{ steps.build_binutils.outputs.bin_dir }}
91+
export PATH=$PATH:${{ steps.fetch_binutils.outputs.bin_dir }}
8592
cd tests
86-
ln -s ../binutils-esp32ulp # already cloned earlier. reuse.
8793
./02_compat_rtc_tests.sh

Diff for: README.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ It can translate small assembly language programs to a loadable/executable
1818
ULP machine code binary, directly on the ESP32 microcontroller.
1919

2020
This is intended as an alternative approach to assembling such programs using
21-
the binutils-esp32ulp toolchain from Espressif on a development machine.
21+
the `binutils-gdb toolchain <https://github.com/espressif/binutils-gdb/tree/esp32ulp-elf-2.35>`_
22+
(esp32-elf-as) from Espressif on a development machine.
2223

23-
It can also be useful in cases where binutils-esp32ulp is not available.
24+
It can also be useful in cases where esp32-elf-as is not available.
2425

2526

2627
Features

Diff for: docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ Testing
151151
-------
152152

153153
There are unit tests and also compatibility tests that check whether the binary
154-
output is identical with what binutils-esp32ulp produces.
154+
output is identical with what Espressif's esp32-elf-as (from their `binutils-gdb fork
155+
<https://github.com/espressif/binutils-gdb/tree/esp32ulp-elf-2.35>`_) produces.
155156

156157
micropython-esp32-ulp has been tested on the Unix port of MicroPython and on real ESP32
157158
devices with the chip type ESP32D0WDQ6 (revision 1) without SPIRAM.

Diff for: tests/01_compat_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ for src_file in $(ls -1 compat/*.S); do
2626

2727
echo -e "\tBuilding using binutils"
2828
gcc -E -o ${pre_file} $src_file
29-
esp32ulp-elf-as -o $obj_file ${pre_file}
29+
esp32ulp-elf-as --mcpu=esp32 -o $obj_file ${pre_file}
3030
esp32ulp-elf-ld -T esp32.ulp.ld -o $elf_file $obj_file
3131
esp32ulp-elf-objcopy -O binary $elf_file $bin_file
3232

Diff for: tests/02_compat_rtc_tests.sh

+11-10
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ fetch_ulptool_examples() {
2727
}
2828

2929
fetch_binutils_esp32ulp_examples() {
30-
[ -d binutils-esp32ulp ] && return
30+
[ -d binutils-gdb ] && return
3131

32-
echo "Fetching binutils-esp32ulp examples"
32+
echo "Fetching binutils-gdb (esp32ulp) examples"
3333
log_file=log/fetch-binutils.log
3434
git clone --depth 1 \
35-
https://github.com/espressif/binutils-esp32ulp.git 1>$log_file 2>&1
35+
-b esp32ulp-elf-v2.35_20220830 \
36+
https://github.com/espressif/binutils-gdb.git 1>$log_file 2>&1
3637
}
3738

3839
build_defines_db() {
@@ -63,7 +64,7 @@ patch_test() {
6364

6465
if [ "${test_name}" = esp32ulp_jumpr ]; then
6566
(
66-
cd binutils-esp32ulp/gas/testsuite/gas/esp32ulp/esp32
67+
cd binutils-gdb/gas/testsuite/gas/esp32ulp/esp32
6768
cp ${test_name}.s ${out_file}
6869
echo -e "\tPatching test to work around binutils-esp32ulp .global bug"
6970
cat >> ${out_file} <<EOF
@@ -74,11 +75,11 @@ EOF
7475

7576
elif [ "${test_name}" = esp32ulp_ranges ]; then
7677
(
77-
cd binutils-esp32ulp/gas/testsuite/gas/esp32ulp/esp32
78+
cd binutils-gdb/gas/testsuite/gas/esp32ulp/esp32
7879
# merge 2 files: https://github.com/espressif/binutils-esp32ulp/blob/249ec34/gas/testsuite/gas/esp32ulp/esp32/check_as_ld.sh#L31
7980
echo -e "\t${test_name} requires esp32ulp_globals. Merging both files into ${out_file}"
8081
cat esp32ulp_globals.s ${test_name}.s > ${out_file}
81-
echo -e "\tPatching test to work around binutils-esp32ulp .global bug"
82+
echo -e "\tPatching test to work around binutils-gdb (esp32ulp) .global bug"
8283
cat >> ${out_file} <<EOF
8384
.global min_add
8485
.global min_jump1
@@ -99,7 +100,7 @@ fetch_ulptool_examples
99100
fetch_binutils_esp32ulp_examples
100101
build_defines_db $1
101102

102-
for src_file in ulptool/src/ulp_examples/*/*.s binutils-esp32ulp/gas/testsuite/gas/esp32ulp/esp32/*.s; do
103+
for src_file in ulptool/src/ulp_examples/*/*.s binutils-gdb/gas/testsuite/gas/esp32ulp/esp32/*.s; do
103104

104105
src_name="${src_file%.s}"
105106
src_dir="${src_name%/*}"
@@ -116,7 +117,7 @@ for src_file in ulptool/src/ulp_examples/*/*.s binutils-esp32ulp/gas/testsuite/g
116117
fi
117118
done
118119

119-
# BEGIN: work around known issues with binutils-esp32ulp
120+
# BEGIN: work around known issues with binutils-gdb (esp32ulp)
120121
ulp_file="${src_name}.ulp"
121122

122123
if patch_test ${test_name}; then
@@ -125,7 +126,7 @@ for src_file in ulptool/src/ulp_examples/*/*.s binutils-esp32ulp/gas/testsuite/g
125126
src_name="${src_file%.tmp}"
126127
ulp_file="${src_name}.tmp.ulp" # when extension is not .s, micropython-esp32-ulp doesn't remove original extension
127128
fi
128-
# END: work around known issues with binutils-esp32ulp
129+
# END: work around known issues with binutils-gdb (esp32ulp)
129130

130131
echo -e "\tBuilding using micropython-esp32-ulp"
131132
log_file="${src_name}.log"
@@ -140,7 +141,7 @@ for src_file in ulptool/src/ulp_examples/*/*.s binutils-esp32ulp/gas/testsuite/g
140141
gcc -I esp-idf/components/soc/esp32/include -I esp-idf/components/esp_common/include \
141142
-x assembler-with-cpp \
142143
-E -o ${pre_file} $src_file
143-
esp32ulp-elf-as -o $obj_file ${pre_file}
144+
esp32ulp-elf-as --mcpu=esp32 -o $obj_file ${pre_file}
144145
esp32ulp-elf-ld -T esp32.ulp.ld -o $elf_file $obj_file
145146
esp32ulp-elf-objcopy -O binary $elf_file $bin_file
146147

0 commit comments

Comments
 (0)