Last active
December 28, 2015 14:49
-
-
Save makestuff/7517475 to your computer and use it in GitHub Desktop.
Generating ARMv2 code with a gcc cross-compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat regs.c | |
typedef unsigned int uint32; | |
#define BLTCON1 *((volatile uint32 *)0xFFFFFF00) | |
#define BLTCON2 *((volatile uint32 *)0xFFFFFF04) | |
#define BLTCON3 *((volatile uint32 *)0xFFFFFF08) | |
void foo(uint32 x, uint32 y, uint32 z) { | |
BLTCON1 = x; | |
BLTCON2 = y; | |
BLTCON3 = z; | |
} | |
$ armeb-unknown-eabi-gcc -march=armv2 -O2 -S -Wall -Wextra -Wundef -Wconversion -pedantic-errors -std=c99 regs.c | |
regs.c:1: warning: target CPU does not support interworking | |
$ cat regs.s | |
.arch armv2 | |
.fpu softvfp | |
.eabi_attribute 20, 1 | |
.eabi_attribute 21, 1 | |
.eabi_attribute 23, 3 | |
.eabi_attribute 24, 1 | |
.eabi_attribute 25, 1 | |
.eabi_attribute 26, 1 | |
.eabi_attribute 30, 2 | |
.eabi_attribute 18, 4 | |
.file "regs.c" | |
.text | |
.align 2 | |
.global foo | |
.type foo, %function | |
foo: | |
@ args = 0, pretend = 0, frame = 0 | |
@ frame_needed = 0, uses_anonymous_args = 0 | |
@ link register save eliminated. | |
mvn r3, #0 | |
str r0, [r3, #-255] | |
str r1, [r3, #-251] | |
str r2, [r3, #-247] | |
mov pc, lr | |
.size foo, .-foo | |
.ident "GCC: (crosstool-NG 1.19.0) 4.3.2" | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.19.0.tar.bz2 | |
bunzip2 -c crosstool-ng-1.19.0.tar.bz2 | tar xf - | |
cd crosstool-ng-1.19.0 | |
./configure --enable-local | |
make | |
./ct-ng armeb-unknown-eabi | |
./ct-ng build | |
export PATH=${PATH}:${HOME}/x-tools/armeb-unknown-eabi/bin | |
armeb-unknown-eabi-gcc -march=armv2 ... |
ghost
commented
Nov 17, 2013
Compiled with -march=armv2 , so this startup routine needs to be converted to a non-thumb instruction set.
||=== HelloWorld, Debug ===|
Setup\startup.S|1|warning: target CPU does not support THUMB instructions [enabled by default]|
Setup\startup.S|84|Error: selected processor does not support ARM mode `bx r0'|
Setup\startup.S|111|Error: selected processor does not support ARM mode `mrs r0,cpsr'|
Setup\startup.S|113|Error: selected processor does not support ARM mode `msr cpsr,r0'|
Setup\startup.S|118|Error: selected processor does not support ARM mode `bx r2'|
Setup\startup.S|128|Error: selected processor does not support ARM mode `bx lr'|
Setup\startup.S|145|Error: selected processor does not support ARM mode `msr CPSR_c,#ARM_MODE_UNDEF|I_BIT|F_BIT'|
Setup\startup.S|148|Error: selected processor does not support ARM mode `msr CPSR_c,#ARM_MODE_ABORT|I_BIT|F_BIT'|
Setup\startup.S|151|Error: selected processor does not support ARM mode `msr CPSR_c,#ARM_MODE_FIQ|I_BIT|F_BIT'|
Setup\startup.S|154|Error: selected processor does not support ARM mode `msr CPSR_c,#ARM_MODE_IRQ|I_BIT|F_BIT'|
Setup\startup.S|157|Error: selected processor does not support ARM mode `msr CPSR_c,#ARM_MODE_SVC|I_BIT|F_BIT'|
Setup\startup.S|167|Error: selected processor does not support ARM mode `bx r0'|
||=== Build finished: 11 errors, 1 warnings (0 minutes, 0 seconds) ===|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment