Skip to content

Commit badbfd5

Browse files
authored
Add make.bat files for the newlib samples (#236) (#238)
This adapts the existing Makefile from the newlib samples to a make.bat so that the samples can be run on Windows.
1 parent 76c1c34 commit badbfd5

File tree

2 files changed

+96
-0
lines changed
  • arm-software/embedded/newlib-samples/src

2 files changed

+96
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@REM Copyright (c) 2025, Arm Limited and affiliates.
2+
@REM
3+
@REM Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
4+
@REM See https://llvm.org/LICENSE.txt for license information.
5+
@REM SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
@if [%1]==[] goto :target_empty
8+
@set target=%1
9+
@goto :make
10+
:target_empty
11+
@set target=build
12+
13+
:make
14+
@if [%target%]==[build] goto :build
15+
@if [%target%]==[run] goto :run
16+
@if [%target%]==[clean] goto :clean
17+
@echo Error: unknown target "%target%"
18+
@exit /B 1
19+
20+
:build
21+
@if [%BIN_PATH%]==[] goto :bin_path_empty
22+
@call :build_fn
23+
@exit /B
24+
25+
:run
26+
@if exist hello.hex goto :do_run
27+
@if [%BIN_PATH%]==[] goto :bin_path_empty
28+
@call :build_fn
29+
:do_run
30+
qemu-system-arm.exe -M microbit -semihosting -nographic -device loader,file=hello.hex -m 1073741824k
31+
@exit /B
32+
33+
:clean
34+
if exist hello.elf del /q hello.elf
35+
if exist hello.hex del /q hello.hex
36+
@exit /B
37+
38+
:bin_path_empty
39+
@echo Error: BIN_PATH environment variable is not set
40+
@exit /B 1
41+
42+
:build_fn
43+
%BIN_PATH%\clang.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -nostartfiles --config=newlib.cfg -lcrt0-rdimon -lrdimon -g -T ..\..\ldscripts\newlib-microbit.ld -o hello.elf hello.c ..\..\startup\startup_ARMCM0.S
44+
%BIN_PATH%\llvm-objcopy.exe -O ihex hello.elf hello.hex
45+
@exit /B
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@REM Copyright (c) 2025, Arm Limited and affiliates.
2+
@REM
3+
@REM Part of the Arm Toolchain project, under the Apache License v2.0 with LLVM Exceptions.
4+
@REM See https://llvm.org/LICENSE.txt for license information.
5+
@REM SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
7+
@if [%1]==[] goto :target_empty
8+
@set target=%1
9+
@goto :make
10+
:target_empty
11+
@set target=build
12+
13+
:make
14+
@if [%target%]==[build] goto :build
15+
@if [%target%]==[run] goto :run
16+
@if [%target%]==[clean] goto :clean
17+
@echo Error: unknown target "%target%"
18+
@exit /B 1
19+
20+
:build
21+
@if [%BIN_PATH%]==[] goto :bin_path_empty
22+
@call :build_fn
23+
@exit /B
24+
25+
:run
26+
@if exist hello.hex goto :do_run
27+
@if [%BIN_PATH%]==[] goto :bin_path_empty
28+
@call :build_fn
29+
:do_run
30+
qemu-system-arm.exe -M mps2-an386 -semihosting -nographic -device loader,file=hello.hex
31+
qemu-system-arm.exe -M mps2-an386 -semihosting -nographic -device loader,file=hello-exn.hex
32+
33+
@exit /B
34+
35+
:clean
36+
if exist hello.elf del /q hello.elf
37+
if exist hello-exn.elf del /q hello-exn.elf
38+
if exist hello.hex del /q hello.hex
39+
if exist hello-exn.hex del /q hello-exn.hex
40+
@exit /B
41+
42+
:bin_path_empty
43+
@echo Error: BIN_PATH environment variable is not set
44+
@exit /B 1
45+
46+
:build_fn
47+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -nostartfiles -fno-exceptions -fno-rtti --config=newlib.cfg -lcrt0-rdimon -lrdimon -g -T ..\..\ldscripts\newlib-cm4.ld -o hello.elf hello.cpp ..\..\startup\startup_ARMCM4.S
48+
%BIN_PATH%\clang++.exe --target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m -mfpu=none -nostartfiles -DTEST_EXN --config=newlib.cfg -lcrt0-rdimon -lrdimon -g -T ..\..\ldscripts\newlib-cm4.ld -o hello-exn.elf hello.cpp ..\..\startup\startup_ARMCM4.S
49+
%BIN_PATH%\llvm-objcopy.exe -O ihex hello.elf hello.hex
50+
%BIN_PATH%\llvm-objcopy.exe -O ihex hello-exn.elf hello-exn.hex
51+
@exit /B

0 commit comments

Comments
 (0)