Go to advanced search

by colinh
Tue Jun 25, 2019 1:41 am
Forum: Bare metal, Assembly language
Topic: Getting interrupts from GPIO (in assembler)
Replies: 9
Views: 6846

Re: Getting interrupts from GPIO (in assembler)

Sorry about the delay in replying -- I haven't logged on in years! In case you haven't already figured it out, you need to read the "Peripherals" document for your chip. See https://www.raspberrypi.org/documentation/hardware/raspberrypi/README.md I used the BCM2835. The IRQ register info is on p.112...
by colinh
Fri Sep 22, 2017 1:59 am
Forum: Bare metal, Assembly language
Topic: Why is toggling GPIO pins not a race condition?
Replies: 12
Views: 3594

Re: Why is toggling GPIO pins not a race condition?

rpdom wrote:
Thu Sep 21, 2017 7:18 pm
John_Uskglass wrote:
Thu Sep 21, 2017 3:58 pm
@rpdom I'll take your word for it! If I were going to share a house with a spid like that though, I think I'd demand at least one Pi per leg ;).
If that were the case, I'd be looking at getting around 400 Pis instead of the 30 or so I have at present.
Hang on! Spiders don't have 13 legs!?
by colinh
Tue Aug 22, 2017 4:35 pm
Forum: Bare metal, Assembly language
Topic: ARM integer v. NEON/VFP float instruction timings
Replies: 3
Views: 1750

ARM integer v. NEON/VFP float instruction timings

A. How do the instruction timings (number of clock cycles) compare for the following instructions: add r0, r1, r2 vadd.s32 q0, q1, q2 // vector integer vadd.f32 q0, q1, q2 // vector floating point vadd.s32 s0, s1, s2 // scalar integer vadd.f32 s0, s1, s2 // scalar floating point mul r0, r1, r2 vmul....
by colinh
Wed Aug 16, 2017 12:14 am
Forum: Bare metal, Assembly language
Topic: pi3 PMU interrupt settings
Replies: 6
Views: 2301

Re: pi3 PMU interrupt settings

Fine, let me rephrase it in a way that's also true. I have my own baremetal OS I am writing and I am trying to get the PMU to work. Does anyone know the proper PMU interrupt number/types for the Pi3? Ooh! Sneaky! I see what you did there. :D For what it's worth, on Linux the PMU interrupt gets assi...
by colinh
Tue Aug 15, 2017 11:43 pm
Forum: Bare metal, Assembly language
Topic: Porting code from Pi Model B to Pi 2 (or Pi 3)
Replies: 10
Views: 2335

Re: Porting code from Pi Model B to Pi 2 (or Pi 3)

The ARM1176JZF-S being ARMv6 with loads of extensions, I think we were supposed to be using the ARMv7-A ARM anyway, no? At least, that's what I think I did for the MMU/cache setup. The only other ARM ARM I have is DDI 100I, which (I think) is for ARMv5. There is no ARMv6-A ARM. Yes, there's no confi...
by colinh
Tue Aug 15, 2017 2:46 am
Forum: Bare metal, Assembly language
Topic: Porting code from Pi Model B to Pi 2 (or Pi 3)
Replies: 10
Views: 2335

Re: Porting code from Pi Model B to Pi 2 (or Pi 3)

OK, so all I actually needed to do was change the peripherals base, and jiggle the framebuffer address. That's it. Anyone want to laugh at why "it still Wasn't Working(TM)"? I started qemu like this: qemu-system-arm -kernel kernel.img -cpu cortex-a7 -m 512 -smp cores=4 -machine raspi2 -serial stdio ...
by colinh
Mon Aug 14, 2017 11:27 pm
Forum: Bare metal, Assembly language
Topic: Porting code from Pi Model B to Pi 2 (or Pi 3)
Replies: 10
Views: 2335

Re: Porting code from Pi Model B to Pi 2 (or Pi 3)

Hi. Thanks for the code. Just a couple of remarks: As might be expected from ARM v7-A ARM, in section B1.9.1 Reset the processor seems to be booting in SVC mode (at least under QEMU); CPSR was 0x400001D3 (after the mrs r0,cpsr instruction at _start:), ie the last 5 bits are 1.0011. And from this htt...
by colinh
Mon Aug 14, 2017 5:09 pm
Forum: Bare metal, Assembly language
Topic: STICKY: Bare Metal resources
Replies: 26
Views: 112658

Re: STICKY: Bare Metal resources

Peter Cockerell's ARM Assembly Language Programming book This excellent book is a wonderful introduction to ARM assembler. It deals with the ancient ARM2 processor (as used in the original Acorn Archimedes computer - back when ARM was Acorn RISC machine :-) ) but almost all of it is still relevant ....
by colinh
Sun Aug 13, 2017 3:09 pm
Forum: Bare metal, Assembly language
Topic: Porting code from Pi Model B to Pi 2 (or Pi 3)
Replies: 10
Views: 2335

Porting code from Pi Model B to Pi 2 (or Pi 3)

A couple of years ago I was writing a hobby OS (in assembly) for the Pi Model B. Then my JTAG interface broke and I discovered Torlus' patched QEMU -- which worked really well and was very convenient. At just about the time the Pi 2 was released (and Torlus's patches were merged into the mainstream ...
by colinh
Sun Aug 13, 2017 2:16 pm
Forum: Bare metal, Assembly language
Topic: Simple VGA Mode X (direct frame buffer) programming
Replies: 8
Views: 3885

Re: Simple VGA Mode X (direct frame buffer) programming

Your code has a small bug which we all had for a while because we all generally started from the same tutorials which do it. [...] Rst can take the credit for being the first to notice we were all doing it wrong and provided code that proved it. https://www.raspberrypi.org/forums/viewtopic.php?t=16...
by colinh
Sun Aug 13, 2017 12:22 am
Forum: Bare metal, Assembly language
Topic: Simple VGA Mode X (direct frame buffer) programming
Replies: 8
Views: 3885

Re: Simple VGA Mode X (direct frame buffer) programming

For the Raspberry Pi 2: // Mailbox_base (Baking Pi/Screen01) //.set MBX_base, 0x2000B880 // for RPi Model B .set MBX_base, 0x3F00B880 .set MBX_READ, 0x00000000 .set MBX_POLL, 0x00000010 .set MBX_SNDR, 0x00000014 .set MBX_STAT, 0x00000018 .set MBX_CONF, 0x0000001C .set MBX_WRITE, 0x00000020 .globl in...
by colinh
Sat Aug 08, 2015 1:15 am
Forum: Teaching and learning resources
Topic: I cannot understand Pi programming.
Replies: 10
Views: 2770

Re: I cannot understand Pi programming.

The Pi has to run an OS, if you want something like that you probably want an Arduino. Err, of course the Pi doesn't need an OS! As ghans mentioned, there's an entire Bare Metal (meaning no OS) forum dedicated to it. Indeed, I would say that if you're coming from microcontrolers, and want to fiddle...
by colinh
Fri Aug 07, 2015 12:23 pm
Forum: Bare metal, Assembly language
Topic: B+ Cycle counter, IRQs, and Wait-for-interrupt
Replies: 2
Views: 849

Re: B+ Cycle counter, IRQs, and Wait-for-interrupt

Without reading up to check, you might want to have a look at the Memory Order Model section of the ARMv6ARM, if you haven't already. Could be a total red herring, but that stuff looks like it could account for a lot of oddities :)
by colinh
Wed Apr 29, 2015 12:12 pm
Forum: Bare metal, Assembly language
Topic: Hobby OSs
Replies: 7
Views: 2126

Hobby OSs

I often see people mentioning their own hobby OS (and may have done so myself, on occasion). I'm curious about other people's OSs (but not to the extent that I want to wade through their code--unless it's really interesting, of course :-) ) a) what would you say yours most resembles in the Real Worl...
by colinh
Mon Apr 20, 2015 10:25 am
Forum: Bare metal, Assembly language
Topic: ARM assembly encodings?
Replies: 13
Views: 2176

Re: ARM assembly encodings?

I can't really figure out what/why you're trying to do either :-) I use OpenOCD (with or without gdb) to debug my bare metal code. Is your stub supposed to be running on the target that you're trying to debug? Or are you trying to implement something like OpenOCD? (In which case looking at the open ...
by colinh
Sun Apr 05, 2015 6:01 pm
Forum: Bare metal, Assembly language
Topic: Streaming 6Mbyte/sec to memory
Replies: 8
Views: 2175

Re: Streaming 6Mbyte/sec to memory

BL7: DMA_BURST_LEN = 7 This is something I was trying out last summer, when my JTAG interface broke. I haven't done any RPi programming since then (until now, where I'm trying out qemu). Sooo, I don't know for certain that the following code snippets work. I might have been in the middle of changing...
by colinh
Sun Apr 05, 2015 2:15 am
Forum: Bare metal, Assembly language
Topic: Streaming 6Mbyte/sec to memory
Replies: 8
Views: 2175

Re: Streaming 6Mbyte/sec to memory

I think I was getting 37.5 Mwords/sec using DMA with BL7 (from GPLEV0 to memory).
by colinh
Sat Apr 04, 2015 7:39 pm
Forum: Bare metal, Assembly language
Topic: Setting up modes?
Replies: 8
Views: 4219

Re: Setting up modes?

I tend only to use the ARM v6 ARM and arm1176jzfs TRM. From the former, 2.6 Exceptions , When an exception occurs, the banked versions of R14 and the SPSR for the exception mode are used to save state as follows: R14_<exception_mode> = return link SPSR_<exception_mode> = CPSR CPSR[4:0] = exception m...
by colinh
Sat Apr 04, 2015 3:01 pm
Forum: Bare metal, Assembly language
Topic: Setting up modes?
Replies: 8
Views: 4219

Re: Setting up modes?

You'll get the hang of it :-) I actually checked in ARM v6 ARM. The _c is described in A3.10 Status register access instructions and A.4.1.39 MSR . The syntax is slightly odd, because the _c is actually part of the MSR instruction. I haven't had to do anything with the SPSR yet. "Each exception mode...
by colinh
Sat Apr 04, 2015 4:36 am
Forum: Bare metal, Assembly language
Topic: Setting up modes?
Replies: 8
Views: 4219

Re: Setting up modes?

This stuff is dealt with in a document called the ARM ARM. There's one for each iteration of the ARM. The latest is ARM v7 ARM, I think. Each version gets more complicated and unpleasant to read than the previous :-) The CPSR is the current program status register, and holds info like processor mode...
by colinh
Fri Apr 03, 2015 7:02 pm
Forum: Bare metal, Assembly language
Topic: Examining Alex's Screen03 on qemu using gdb
Replies: 1
Views: 1069

Examining Alex's Screen03 on qemu using gdb

This is a slightly odd (and long) post, since it doesn't pose any immediate questions (although I'd appreciate any corrections/clarifications), but rather documents my attempts at getting everything running, in the hope that some of it might be useful to a beginner... Due to the temporary lack of a ...
by colinh
Thu Apr 02, 2015 6:26 pm
Forum: Bare metal, Assembly language
Topic: Good asm-learning books?
Replies: 22
Views: 3162

Re: Good asm-learning books?

The (free) book mentioned here is, IMHO, good. http://www.raspberrypi.org/forums/viewtopic.php?f=72&t=64010&p=472980&hilit=cockerell#p472980 Thanks. I have seen it, but I thought it's helplessly outdated. But now that in the thread you mentioned ...but almost all of it is still relevant. I started ...
by colinh
Thu Apr 02, 2015 12:51 am
Forum: Bare metal, Assembly language
Topic: Good asm-learning books?
Replies: 22
Views: 3162

Re: Good asm-learning books?

The (free) book mentioned here is, IMHO, good.

http://www.raspberrypi.org/forums/viewt ... ll#p472980
by colinh
Thu Mar 26, 2015 11:18 am
Forum: Bare metal, Assembly language
Topic: Coding in HEX
Replies: 41
Views: 10199

Re: Coding in HEX

That's why I hate also C, and because of C exist hackers. If I have somebody to help me]I can build a server imposible to brake. I will do it anyway starting from next year when I will have enough money to eat, and stay relax. I need only one month to read books of Assembler for x86, one month to m...
by colinh
Wed Aug 27, 2014 9:53 pm
Forum: Bare metal, Assembly language
Topic: Distinguishing source of interrupt
Replies: 1
Views: 937

Re: Distinguishing source of interrupt

Yes, there are registers like that :-)

Have a look at http://www.raspberrypi.org/wp-content/u ... herals.pdf

See the sections on Interrupts and on the peripherals you're interested in.

Go to advanced search