Go to advanced search

by blippy
Tue Aug 17, 2021 11:37 am
Forum: Bare metal, Assembly language
Topic: Fast way to move memory?
Replies: 20
Views: 2416

Re: Fast way to move memory?

I have some non-working code: #include <gpio.h> #include <stdio.h> #include <timers.h> // DMA control block (must be 32-byte aligned) typedef struct __attribute__((packed)) { uint32_t ti, // Transfer info src, // Source address dest, // Destination address tfr_len, // Transfer length stride, // Tran...
by blippy
Mon Aug 16, 2021 9:10 pm
Forum: Bare metal, Assembly language
Topic: Fast way to move memory?
Replies: 20
Views: 2416

Re: Fast way to move memory?

Aligning to a word boundary and then coping words will over four times faster. In assembler doing four words at once will be even faster. I guess, but the speedup I saw a few years ago was way faster than that. I can only presume that there's something in VideoCore (??) that does memory operations ...
by blippy
Mon Aug 16, 2021 8:37 pm
Forum: Bare metal, Assembly language
Topic: Fast way to move memory?
Replies: 20
Views: 2416

Re: Fast way to move memory?

Show us your code. All of it?? Here's my version of memcpy(); void *memcpy(void *dest, const void *src, size_t n) { char *d = dest; while(n--) *d++ = *(char*)src++; return dest; } Here's my code relating to the framebuffer: #include <stdio.h> #include <string.h> #include <basal.h> #include <lfb.h> ...
by blippy
Mon Aug 16, 2021 7:57 pm
Forum: Bare metal, Assembly language
Topic: Fast way to move memory?
Replies: 20
Views: 2416

Re: Fast way to move memory?

Does that mean the copy is overlapped ? That makes it rather more difficult. In C you would have to use memmove instead of memcpy. That's probably not an issue, though, as the dest addr is lower than the src addr. In my tests so far, everything works. The real problem is speed. I'm pretty sure ther...
by blippy
Mon Aug 16, 2021 6:19 pm
Forum: Bare metal, Assembly language
Topic: Fast way to move memory?
Replies: 20
Views: 2416

Fast way to move memory?

I've been messing around with framebuffers in Pi0, bare metal. To scroll the buffer I use a hand-rolled version of memcpy. It is slow. I figure that there must be a way of performing a memcpy using hardware, but I can't find any resources. Can anyone give any pointers?
by blippy
Sat Aug 14, 2021 3:54 pm
Forum: Other RP2040 boards
Topic: Maker Pico SD card unreliable
Replies: 7
Views: 2357

Re: Maker Pico SD card unreliable

Hmmm, here's a thing ... I have been writing some test code on Linux. The thing about the failing card is that it had a Raspberry OS install. I couldn't find the partition table as I expected it. I think maybe that the card gets formatted to GPT rather than an MBR, so this is what might have been ca...
by blippy
Wed Aug 04, 2021 9:08 am
Forum: SDK
Topic: Issues with spi on pico as slave!
Replies: 4
Views: 1216

Re: Issues with spi on pico as slave!

Just a little followup ... I notice that this thread also discusses SPI master and slaves: https://www.raspberrypi.org/forums/viewtopic.php?f=145&t=300589 One point they raised is that in a multi-byte transfer, the Pico toggles the CS pin if you gpio_set_function(PIN_CS, GPIO_FUNC_SPI); Others h...
by blippy
Tue Aug 03, 2021 8:43 pm
Forum: SDK
Topic: Issues with spi on pico as slave!
Replies: 4
Views: 1216

Re: Issues with spi on pico as slave!

Hmmm, maybe not ideal, but I created a spi slave that sends data. It uses interrupts instead of a SPI peripheral, because, well, I haven't figured out how to do it. Some example code: #include <stdio.h> #include <string.h> #include "pico/stdlib.h" //#include "hardware/adc.h" //#i...
by blippy
Tue Aug 03, 2021 6:46 pm
Forum: SDK
Topic: Issues with spi on pico as slave!
Replies: 4
Views: 1216

Re: Issues with spi on pico as slave!

I'm trying to create a spi slave, too, but not having any luck. There is a mention of it at https://github.com/raspberrypi/pico-examples/issues/26 and https://github.com/raspberrypi/pico-examples/pull/101 but it doesn't to seem to either exist/work. It would be useful if one of the Pi Engineers coul...
by blippy
Thu Jul 22, 2021 3:21 pm
Forum: Other RP2040 boards
Topic: Maker Pico SD card unreliable
Replies: 7
Views: 2357

Re: Maker Pico SD card unreliable

matherp wrote:
Thu Jul 22, 2021 12:59 pm
The input I/O on the Pico seems inherently unreliable UNTIL you switch on hysteresis for ths pins used.
Oh. That's interesting. Thanks for the heads-up.
by blippy
Sat Jun 12, 2021 8:49 am
Forum: SDK
Topic: Using picoprobe/openocd as a stlink and serial?
Replies: 3
Views: 652

Using picoprobe/openocd as a stlink and serial?

The picoprobe can be used simultaneously as pico programmer and serial port. I'm wondering if the same can be done with an STM32 as a target. I tried the following: sudo openocd -f interface/picoprobe.cfg -f target/stm32f4x.cfg -s tcl but obtained the result: Open On-Chip Debugger 0.10.0+dev-geb22ac...
by blippy
Wed Jun 02, 2021 3:49 pm
Forum: SDK
Topic: repeating_timer_callback assertion failure
Replies: 6
Views: 597

Re: repeating_timer_callback assertion failure

I only turned on debugging because I was having problems. So I don't think that's the cause of my problems. As regards your second point, I'm afraid I don't understand the concepts involved. Perhaps you could elucidate. So XIP is the external flash memory, which is slow? And SRAM is memory on the ch...
by blippy
Wed Jun 02, 2021 11:29 am
Forum: SDK
Topic: repeating_timer_callback assertion failure
Replies: 6
Views: 597

Re: repeating_timer_callback assertion failure

I decided to try switching to low-level timing based on one of the sdk-examples (great resource, BTW!), and that fixed my issues. I was able to generate signals at 40kHz. I could undoubtedly go higher, but that is sufficient for my purposes. I use floating-point arithmetic. In tests that I've done e...
by blippy
Mon May 31, 2021 6:10 pm
Forum: SDK
Topic: repeating_timer_callback assertion failure
Replies: 6
Views: 597

Re: repeating_timer_callback assertion failure

A follow-up ... OK, so I did an experiment in which I timed my callback and adjusted the repeating interval until everything failed. My callback took 20us, and using a repeating interval of 76us it was close to the edge. This implies that the SDK callback infrastructure takes around 56us to make a c...
by blippy
Mon May 31, 2021 2:13 pm
Forum: SDK
Topic: repeating_timer_callback assertion failure
Replies: 6
Views: 597

Re: repeating_timer_callback assertion failure

Just a little update: the value for rt->alarm_id was 268441919, which I assume is way out. The id parameter was optimised out by the compiler. Hmmm. I guess that's OK. repeating_timer_callback() appears to be called from alarm_pool_add_alarm_at() (time.c line 230), which passes in a parameter of pub...
by blippy
Mon May 31, 2021 1:59 pm
Forum: SDK
Topic: repeating_timer_callback assertion failure
Replies: 6
Views: 597

repeating_timer_callback assertion failure

Hmmm, this is bizarre. I compiled my code with debug turned on and used a repeating timer using add_repeating_timer_us(repeat_us, callback, 0, &timer); One of the examples given has user_data as NULL, so I think using a value of 0 is OK. Now here's the bizarre thing. When I run my code with a re...
by blippy
Sun May 30, 2021 8:18 pm
Forum: General
Topic: Formatting SD cards under Linux
Replies: 6
Views: 718

Re: Formatting SD cards under Linux

I saw on Reddit that someone was asking about SD cards. For anyone interested, I have at least something working over at: https://github.com/blippy/rpi/tree/master/pico/sdcard Now, I'm not saying it's pretty, but it's at least a first stab at piecing thing together. File systems are NOT supported, n...
by blippy
Sun May 30, 2021 1:39 pm
Forum: SDK
Topic: random bit example, please
Replies: 3
Views: 549

Re: random bit example, please

I've had the opportunity to have another play with random numbers. I think that, in my original example, I had a fried GPIO pin. D'oh. My code is now like this: #include <stdio.h> #include <stdlib.h> #include <string.h> #include "pico/stdlib.h" //#include "hardware/spi.h" #includ...
by blippy
Sat May 29, 2021 11:04 am
Forum: SDK
Topic: openocd LIBUSB_ERROR_ACCESS
Replies: 25
Views: 1679

openocd LIBUSB_ERROR_ACCESS

I'm using a spare Pico as a debugger. If I type openocd -f interface/picoprobe.cfg -f target/rp2040.cfg -s tcl I get the response Open On-Chip Debugger 0.10.0+dev-geb22ace-dirty (2021-05-29-10:51) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : only on...
by blippy
Thu May 27, 2021 11:37 am
Forum: General
Topic: Formatting SD cards under Linux
Replies: 6
Views: 718

Re: Formatting SD cards under Linux

I'm in the process of writing my own card library, which I'm adapting from CircuitPython. I'm getting a failure to set the card to an idle state, which is the first thing that needs to be done. Hmmm, interesting. I read somewhere that pullup resistors should be used, so maybe I'll try that. The card...
by blippy
Wed May 26, 2021 2:29 pm
Forum: SDK
Topic: Recommended replacement for "volatile"?
Replies: 7
Views: 702

Recommended replacement for "volatile"?

For my ISRs I've been using volatile variables, which seem necessary. C++20 deprecates the "volatile" keyword, so I'm wondering what should be used in its place.
by blippy
Sat May 22, 2021 2:48 pm
Forum: General
Topic: Formatting SD cards under Linux
Replies: 6
Views: 718

Formatting SD cards under Linux

In another thread I reported that SD cards seem highly unreliable when used with MCUs. I'm wondering if it might have something to do with either the size of the partition or the exact file format. FAT32 has an extended format, for example, and I'm wondering whether the standard Linux tools create a...
by blippy
Sat May 22, 2021 2:26 pm
Forum: Other RP2040 boards
Topic: Maker Pico SD card unreliable
Replies: 7
Views: 2357

Maker Pico SD card unreliable

I bought a Maker Pico board recently, and I was keen to test out the SD card. It seems unreliable, though. If I start the board and press the GP22 button to test the card, it responds "no sd card". However, if I start the board and press GP20, wait for it to finish, and then press GP22, th...
by blippy
Thu Apr 29, 2021 2:08 pm
Forum: SDK
Topic: Can't seem to store on flash
Replies: 21
Views: 792

Re: Can't seem to store on flash

OK, thanks for the info, guys. I managed to get stuff working. For those interested in seeing my final code, check out this link: https://github.com/blippy/rpi/tree/master/pico/flash I've summarised the discussion, and provided some guidance for those who may have faced similar problems, in that lin...
by blippy
Thu Apr 29, 2021 8:46 am
Forum: SDK
Topic: Can't seem to store on flash
Replies: 21
Views: 792

Re: Can't seem to store on flash

rpdom wrote:
Thu Apr 29, 2021 8:38 am

(I think it's something like you can set a bit, but not unset it. You can only reset pages of bits at a time and that is slow).
Ah, I see. That would make sense, then.

It would be nice to see the SDK mention this fact, because it's certainly non-obvious.

Go to advanced search