GithubHelp home page GithubHelp logo

pico-extras's Introduction

This repo has additional libraries that are not yet ready for inclusion the Pico SDK proper, or are just useful but don't necessarily belong in the Pico SDK.

Note that any API here is a work in progress and subject to change.

See pico-playground for buildable example code using these extra libraries.

Library Description
hardware_rosc API for the ring oscillator
lwip Deprecated as of SDK 1.5.0; use pico_lwip and pico_lwip_arch from the SDK instead.
pico_audio Audio output support; this is highly functional, but the API is subject to change
   pico_audio_i2s Audio output via I2S on 3 GPIOs using PIO. Arbitrary frequency
   pico_audio_pwm Audio output via (PIO) PWM. Currently a bit limited in frequency support (it was developed on FPGA to do 22050Hz at 48Mhz system clock). It does however support error diffusion dithering and noise shaping with 16x oversampling to give surprisingly good audio quality. This code will be split to provide both a fixed frequencie(s) version and a slightly slower but rather better arbitrary frequency version supporting ever higher carrier frequencies
   pico_audio_spdif Audio output in S/PDIF on a GPIO using PIO. Supports up to 192khz stereo. Consumed OK in test, haven't tried it with real hardware
pico_sd_card 1 and 4 bit SDIO support using PIO. This is functional (currently writing is only 1 bit), but the code is very much a prototype and the API is just a placeholder - the command set needs to be separated from the SDIO and shared with SPI. A reference design for an SD card interface can be found in the Hardware design with RP2040 datasheet.
pico_sleep Low power related APIs, WIP because they are not sufficiently generic and also only handle core 0
pico_scanvideo Support for video output where every pixel is scanned out every frame. VGA/DPI support is highly functional and stable, but the API is subject to change. A reference design for a VGA board can be found in the Hardware design with RP2040 datasheet.
   pico_scanvideo_dbi currently non-compiling... placeholder for adding scanvideo over MIPI DBI support.
   pico_scanvideo_dpi Highly functional and stable support for parallel RGB output and VSYNC/HSYNC/DEN/CLOCK for VGA/DPI.
pico_util_buffer Rather incomplete buffer abstraction, used by pico_audio and pico_scanvideo
platypus Decoder for a custom image compression format suitable for dithered images (good for RGB555) and suitable for decoding on RP2040 at scanline speeds ... i.e you can easily decode a 320x240 image 60x per second to avoid storing the uncompressed image for scanout video. It gets about 50% compression (but is designed only for 4x4 fixed dithered RGB555 images, so is somewhat specific!). TODO add the encoder here :-)
usb_device, usb_common The custom and somewhat minimal USB device stack used in the bootrom. We now use TinyUSB in the Pico SDK but kept here for posterity
usb_device_msc USB Mass Storage Class implementation using usb_device

You can add Pico Extras to your project similarly to the SDK (copying external/pico_extras_import.cmake into your project) having set the PICO_EXTRAS_PATH variable in your environment or via cmake variable.

cmake_minimum_required(VERSION 3.12)

# Pull in PICO SDK (must be before project)
include(pico_sdk_import.cmake)

# We also need PICO EXTRAS
include(pico_extras_import.cmake)

project(pico_playground C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

Alternative you can inject it into an existing project without modifying it via PICO_CMAKE_POST_LIST_DIRS by passing -DPICO_SDK_POST_LIST_DIRS=/path/to/pico_extras to cmake

pico-extras's People

Contributors

alexstanoev avatar ali1234 avatar daft-freak avatar hexpwn avatar jamesh65 avatar kilograham avatar lurch avatar martindevans avatar michaelbell avatar micrub avatar mringwal avatar neywiny avatar sokratisvas avatar tannewt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pico-extras's Issues

stuck DMA in sd_readblocks_sync

After having initialised SD card access using sd_init_1pin(), calling sd_readblocks_sync() with a count > 1 results in the following error message:

stuck dma channel 11 rem 00000002 1 @ 12

The following information may or may not be relevant:

My CMakeLists.txt file includes:

pico_enable_stdio_uart(pico-memu 1)
pico_enable_stdio_usb(pico-memu 0)
pico_add_extra_outputs(pico-memu)
target_link_libraries(pico-memu PRIVATE
  pico_stdlib
  pico_sd_card
  pico_scanvideo_dpi
  pico_multicore
  tinyusb_host
  )

I am running scanvideo on core 0, and usb_host (hid) and sd_card on core 1.

My Pico is clocked at 200MHz.

I have found that after calling sd_init_1pin(), it is necessary to call setup_default_uart() again in order to obtain any further UART output.

Default I2S output to different GPIO pins?

When I was building usb_sound_card from the pico-playground repo, I had to define a different set of GPIO pins in the CMakeLists.txt file because GP25 was not exposed on the Raspberry Pi Pico.

#ifndef PICO_AUDIO_I2S_DATA_PIN
//#warning PICO_AUDIO_I2S_DATA_PIN should be defined when using AUDIO_I2S
#define PICO_AUDIO_I2S_DATA_PIN 27
#endif
#ifndef PICO_AUDIO_I2S_CLOCK_PIN_BASE
//#warning PICO_AUDIO_I2S_CLOCK_PIN_BASE should be defined when using AUDIO_I2S
#define PICO_AUDIO_I2S_CLOCK_PIN_BASE 25
#endif

So, a default PICO_AUDIO_I2S_CLOCK_PIN_BASE of 25 doesn't sound great. Shouldn't this be a different pin? In my case, I set PICO_AUDIO_I2S_CLOCK_PIN_BASE to 26 and PICO_AUDIO_I2S_DATA_PIN to 28. This leaves the WS signal, which then is 27 because that is PICO_AUDIO_I2S_CLOCK_PIN_BASE+1. All of these pins are exposed on the Pico.

PICO_EXTRAS_FETCH_FROM_GIT does not work

Steps to reproduce:

  1. Make a new directory.
  2. Put pico_extras_import.cmake in it.
  3. Create CMakeLists.txt with the following contents:
include(pico_extras_import.cmake)
  1. Create a build directory and enter it.
  2. Run cmake -DPICO_EXTRAS_FETCH_FROM_GIT=1 ..

Expected result:

The pico extras repository should be downloaded and added as a subdirectory of the current project.

Actual result:

The pico extras repository is downloaded and then ${CMAKE_BINARY_DIR} is added as a subdirectory. This directory contains no CMakeLists.txt so cmake errors out, and the project cannot be built.

scanvideo.c fails to compile with enhanced compiler checking enabled

In trying to resolve a problem with one of my programs I added the command

add_compile_options(-Werror -Wall -Wextra -Wnull-dereference)

to my CMakeLists.txt file. This results in a number of warnings for scanvideo.c

/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c: In function 'scanline_id_after':
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:418:13: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
     if (tmp < video_mode.height - 1) {
             ^
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c: In function 'default_scanvideo_scanline_repeat_count_fn':
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1045:65: error: unused parameter 'scanline_id' [-Werror=unused-parameter]
 static uint default_scanvideo_scanline_repeat_count_fn(uint32_t scanline_id) {
                                                                 ^~~~~~~~~~~
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c: In function 'video_24mhz_composable_adapt_for_mode':
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1594:75: error: unused parameter 'program' [-Werror=unused-parameter]
 bool video_24mhz_composable_adapt_for_mode(const scanvideo_pio_program_t *program, const scanvideo_mode_t *mode,
                                                                           ^~~~~~~
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c: In function 'video_default_adapt_for_mode':
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1650:66: error: unused parameter 'program' [-Werror=unused-parameter]
 bool video_default_adapt_for_mode(const scanvideo_pio_program_t *program, const scanvideo_mode_t *mode,
                                                                  ^~~~~~~
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1650:99: error: unused parameter 'mode' [-Werror=unused-parameter]
 bool video_default_adapt_for_mode(const scanvideo_pio_program_t *program, const scanvideo_mode_t *mode,
                                                                                                   ^~~~
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1651:45: error: unused parameter 'modifiable_instructions' [-Werror=unused-parameter]
                                   uint16_t *modifiable_instructions) {
                                             ^~~~~~~~~~~~~~~~~~~~~~~
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c: In function 'scanvideo_default_configure_pio':
/home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1655:67: error: unused parameter 'offset' [-Werror=unused-parameter]
 void scanvideo_default_configure_pio(pio_hw_t *pio, uint sm, uint offset, pio_sm_config *config, bool overlay) {
                                                                   ^~~~~~

While I can, for now remove the -Werror option to get the build to complete, the code should ideally be free of warnings, see the discussion in https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=312978

Add i2s audio input

In the readme it's mentioned that i2s is only for audio output. Is it possible to add i2s audio input or does it maybe already exist?

NULL pointer dereference in scanvideo_begin_scanline_generation

If:

  • routine scanvideo_begin_scanline_generation is called with block = false,
  • there are no available buffers on shared_state.free_list.free_list
  • and PICO_SCANVIDEO_LINKED_SCANLINE_BUFFERS is true

then at line 1092 of scanvideo,c:

  • the variable fsb is NULL
  • and is dereferenced.

This line should probably be moved up to line 1081.

pico_audio_pwm - How does noise shaping work?

In samples_encoding.cpp, there is a section that is defined out (lines 309 - 382) that seems to describe noise shaping implemented using the RP2040 interpolator.

I was unable to find a reference to what the function interp_configure_with_signed_and_cross_result in line 324. I understand that it has something to do with interpolator configuration, but I am not sure which function parameters correspond to which control/base/accumulator registers.

Since the comments are rather sparse, I am finding it difficult to understand how exactly the noise shaping is happening.

I would be grateful if some light could be shed on how this works.

Documentation for audio libraries?

I was wondering if there is any plan to add documentation for the audio libraries. Even some basic description and hints for usage in the files would be a big help.

Create pico-nofrills example library

This would set a bunch of build defines as an example of removing a bunch of runtime support you don't necessarily want when you are looking for every last ounce of space in your runtime working set/binary

How do I use PIO to drive VGA display

I have drawn a Board according to the RPI-PVSA VGA,SD Card&Audio Demo Board for Pico schematic.

Now I want to test the VGA function

but I can't find the examples.

Where can I find it?

Unexpected result in SCANVIDEO if sync pins below colour pins

I am trying to build a VGA interface using only 8 GPIO pins. Two pins for sync and two pins each for red, green and blue.

This is not currently working for my board.

If I have the following definitions in my board header file:

#define PICO_SCANVIDEO_SYNC_PIN_BASE 6
#define PICO_SCANVIDEO_HSYNC_PIN 6
#define PICO_SCANVIDEO_VSYNC_PIN 7
#define PICO_SCANVIDEO_ALPHA_PIN -1
#define PICO_SCANVIDEO_COLOR_PIN_BASE 0
#define PICO_SCANVIDEO_COLOR_PIN_COUNT 6
#define PICO_SCANVIDEO_PIXEL_RSHIFT 0
#define PICO_SCANVIDEO_PIXEL_GSHIFT 2
#define PICO_SCANVIDEO_PIXEL_BSHIFT 4
#define PICO_SCANVIDEO_PIXEL_RCOUNT 2
#define PICO_SCANVIDEO_PIXEL_GCOUNT 2
#define PICO_SCANVIDEO_PIXEL_BCOUNT 2

Then, loading this onto the Pico I measure the expected 31.25kHz on GPIO 6 and 60Hz on GPIO 7.

However, my board has the pins in a different order. If I compile with the following board definition:

#define PICO_SCANVIDEO_SYNC_PIN_BASE 0
#define PICO_SCANVIDEO_HSYNC_PIN 0
#define PICO_SCANVIDEO_VSYNC_PIN 1
#define PICO_SCANVIDEO_ALPHA_PIN -1
#define PICO_SCANVIDEO_COLOR_PIN_BASE 2
#define PICO_SCANVIDEO_COLOR_PIN_COUNT 6
#define PICO_SCANVIDEO_PIXEL_RSHIFT 0
#define PICO_SCANVIDEO_PIXEL_GSHIFT 2
#define PICO_SCANVIDEO_PIXEL_BSHIFT 4
#define PICO_SCANVIDEO_PIXEL_RCOUNT 2
#define PICO_SCANVIDEO_PIXEL_GCOUNT 2
#define PICO_SCANVIDEO_PIXEL_BCOUNT 2

and load the resulting executable onto the Pico, I get the expected 60Hz on GPIO 1, but GPIO 0 measures 25MHz!

So it appears that, for some reason, if the sync pins are below the colour pins, what should be HSYNC is actually the pixel clock.

Any obvious reason for this?

pico_audio_i2s incompatible with USB stdio

It seems that the pico_audio_i2s library intermittently breaks the standard USB stdio implementation, resulting in no communication either way between the pico and the USB host after a short time (a few seconds to a minute or so).

The host still reports the USB CDC connection (e.g. /dev/ttyACM0 continues to exist) but communication ceases.

For example, the pico-playground sine_wave example exhibits this problem, if USB communication is enabled through adding pico_enable_stdio_usb(sine_wave_i2s 1) to the i2s section of CMakeLists.txt. (In that example, the problem is evident as the terminal user interface initially works, then ceases to function).

Is this a known issue -- and is there a known workaround?

Maximum Recursion Depth when adding include(pico_extras_import.cmake)

Hi,
as soon as I add these two lines to my CMakeLists.txt of pico-examples:

set(PICO_EXTRAS_PATH "S:/Programming/Pico/Downloads/pico-extras/")
include(pico_extras_import.cmake)

I get an error saying

PICO_SDK_PATH is S:/Programming/Pico/Downloads/pico-sdk
PICO platform is rp2040.
CMake Error at S:/Programming/Pico/Downloads/pico-sdk/pico_sdk_init.cmake:8 (if):
  Maximum recursion depth of 1000 exceeded
Call Stack (most recent call first):
  pico_sdk_import.cmake:62 (include)
  CMakeLists.txt:4 (include)


-- Configuring incomplete, errors occurred!
See also "S:/Programming/Pico/Downloads/pico-examples/build/CMakeFiles/CMakeOutput.log".
See also "S:/Programming/Pico/Downloads/pico-examples/build/CMakeFiles/CMakeError.log".

How can I fix it?
Any help would be appreciated!

pico_audio_pwm: `take_audio_buffer` never returns null

We've been tinkering with audio on PicoSystem and in the case of at least PWM audio, take_audio_buffer never seems to return null, and never seems to stall for any length of time.

In instances where we're naively calling an "audio_update" function at an arbitrary speed (too quickly in our case) this results in the audio engine getting clocked at some multiple it's intended speed, since we're relying upon take_audio_buffer to give us a buffer if and only if there is an consumed buffer in the pool.

For example, our update_audio function might look something like this:

void update_audio(uint32_t time) {
  struct audio_buffer *buffer = take_audio_buffer(audio_pool, false);
  if(buffer) {
    auto samples = (int16_t *) buffer->buffer->bytes;
    for(uint32_t i = 0; i < buffer->max_sample_count; i++) {
      *samples++ = get_audio_frame();
    }
  }
  buffer->sample_count = buffer->max_sample_count;
  give_audio_buffer(audio_pool, buffer);
}

And this would be called continuously in the main loop.

No matter how fast we run this, if(buffer) is always true.

Scanvideo: hpulse for 640x480

In vga_modes.c line 428 h_pulse is set to 64. This results in my monitor displaying the screen image shifted, resulting in pixels on the right hand side of the image not being displayed.

Should it be set to 96? Other sources, e.g.
http://tinyvga.com/vga-timing/640x480@60Hz
https://vanhunteradams.com/Pico/VGA/VGA.html#Video-explanation
https://gregchadwick.co.uk/blog/playing-with-the-pico-pt5/
indicate this.

When I change the value to 96 my monitor displays the full screen image correctly

CMake 3.12 or higher is required. You are running version 3.7.2

Hi,

Does the latest commit fix this issue?

Adding PICO_EXTRAS_PATH to ~/.bashrc
Cloning https://github.com/raspberrypi/pico-playground.git
Cloning into 'pico-playground'...
remote: Enumerating objects: 196, done.
remote: Counting objects: 100% (196/196), done.
remote: Compressing objects: 100% (144/144), done.
remote: Total 196 (delta 60), reused 174 (delta 46), pack-reused 0
Receiving objects: 100% (196/196), 1.87 MiB | 3.07 MiB/s, done.
Resolving deltas: 100% (60/60), done.
Adding PICO_PLAYGROUND_PATH to ~/.bashrc
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.12 or higher is required. You are running version 3.7.2

-- Configuring incomplete, errors occurred!

audio_i2s.pio comment regarding FIFO word reverses channels

The comment in audio_i2s.pio explaining the word format reverses the 'ws' (LRCLK) value. The PIO sends the first (most significant) 16 bits with LRCLK = 1 and the second with LRCLK = 0. For stereo samples the second 16-bit half in memory corresponds to bits 31:16 and hence is the right channel (assuming I2S where LRCLK = 0 for left).

; Autopull must be enabled, with threshold set to 32.
; Since I2S is MSB-first, shift direction should be to left.
; Hence the format of the FIFO word is:
;
; | 31   :   16 | 15   :    0 |
; | sample ws=0 | sample ws=1 |

MQTT with keep_alive=0 (zero) causes invalid arguments on broker/server and the connection terminates.

Pico W SDK: 1.4.0
IDE: CLion on Ubuntu 22.04 running on a PC:
GCC: 11.2.0 (Ubuntu 11.2.0-19ubuntu1)
MQTT broker/server: Mosquitto 2.0.15 running on Ubuntu 22.04.

Issue: MQTT with keep_alive=0 (zero) causes invalid arguments on broker/server and the connection terminates.

....
  /* Initialize and configure the client info structure */
  struct mqtt_connect_client_info_t clientInfo;
  clientInfo.client_id = MQTT_CLIENT_ID;
  clientInfo.client_user = MQTT_USER;
  clientInfo.client_pass = MQTT_USER_PASSWD;
  clientInfo.keep_alive = 0; <<<<<<<<<<<<< NOTE THIS !!!!!!!!!!!!!!!!!!!!!!!!!
  clientInfo.will_topic = NULL; // set to NULL if will is not to be used, will_msg, will_qos and will retain are then ignored
  clientInfo.will_msg = NULL;
  clientInfo.will_qos = 0;
  clientInfo.will_retain = 0;

  err = mqtt_client_connect(
    client,
    &brokerAddr,
    MQTT_PORT,
    mqttConnectionCallback,
    NULL,
    &clientInfo
  );
....

Generates the following log entries on the Mosquitto broker/server:

1666604114: New connection from 10.3.17.135:53231 on port 1883.
1666604114: New client connected from 10.3.17.135:53231 as picow (p2, c1, k0, u'test').
1666604114: Bad socket read/write on client picow: Invalid arguments provided.

[Help Wanted] examples or success stories for scanvideo with parallel LCD (RGB, H+VSYNC, DEN + PCLK)

Has anyone had success with using scanvideo with a parallel LCD (i.e., 8 Bits RED, GREEN + BLUE, H+VSYNC, DEN and PCLK)? I have this working with the Pi B+ (https://forums.raspberrypi.com/viewtopic.php?t=86658&start=150#p691260) using DPI, but would really like to try on the Pico.

I haven't yet tried myself but will do soon. Additionally, any idea where the GPIO pins are defined in the scanvideo library? I haven't really found where DEN and PCLK could be defined if PICO_SCANVIDEO_ENABLE_DEN_PIN and PICO_SCANVIDEO_ENABLE_CLOCK_PIN are defined.

SCANVIDEO fails while saving to flash from other core

I have a multicore program in which core 1 generates VGA output using pico_scanvideo_dpi, while the other core may (on request) save data to Flash.

My render_loop is declared as __time_critical_func() and therefore is RAM resident (confirmed from the load map). However whenever Flash is written, video generation halts and does not resume until the Pico is reset.

Running under gdb-multiarch and doing a back-trace after the write to flash consistently shows:

`set init
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ee msp: 0x20041f00
(gdb) load
Loading section .boot2, size 0x100 lma 0x10000000
Loading section .text, size 0x31b30 lma 0x10000100
Loading section .rodata, size 0x6648 lma 0x10031c30
Loading section .ARM.exidx, size 0x8 lma 0x10038278
Loading section .binary_info, size 0x3c lma 0x10038280
Loading section .data, size 0x2b68 lma 0x100382bc
Start address 0x100001e8, load size 241188
Transfer rate: 77 KB/sec, 12694 bytes/write.
(gdb) c
Continuing.
^Ctarget halted due to debug-request, current mode: Handler HardFault
xPSR: 0x81000003 pc: 0x1166dfdc msp: 0x20041f58

Thread 1 received signal SIGINT, Interrupt.
0x11051d00 in ?? ()
(gdb) thread 2
[Switching to thread 2 (Thread 2)]
#0 0x1166dfdc in ?? ()
(gdb) bt
#0 0x1166dfdc in ?? ()
#1
#2 0x14000010 in ?? ()
#3 0x20000c76 in set_next_scanline_id (scanline_id=)
at /home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:669
#4 prepare_for_active_scanline_irqs_enabled ()
at /home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:787
#5 isr_irq7 () at /home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:932
#6
#7 0x20001532 in __wfe () at /home/pi/pico/pico-sdk/src/rp2_common/hardware_sync/include/hardware/sync.h:123
#8 scanvideo_begin_scanline_generation (block=block@entry=true)
at /home/pi/pico/pico-extras/src/rp2_common/pico_scanvideo_dpi/scanvideo.c:1085
#9 0x200005d8 in render_loop () at /home/pi/pico/BBCSDL_Work/mcu/pico_vga/picovdu.c:577
#10 0x1001b7d2 in setup_video () at /home/pi/pico/BBCSDL_Work/mcu/pico_vga/picovdu.c:680
#11 0x10022808 in core1_wrapper (entry=0x1001b761 <setup_video>, stack_base=)
at /home/pi/pico/pico-sdk/src/rp2_common/pico_multicore/multicore.c:89
#12 0x00000172 in ?? ()
`
Routine set_next_scanline_id () is always the first identifiable routine in the back-trace

static void set_next_scanline_id(uint32_t scanline_id) { shared_state.scanline.next_scanline_id = scanline_id; shared_state.scanline.y_repeat_target = _scanline_repeat_count_fn(scanline_id) * video_mode.yscale; }
I tried modifying the definition of this routine to:

static void __video_most_time_critical_func(set_next_scanline_id)(uint32_t scanline_id)

but this did not help. Since the function is declared as static it does not appear in the load map to confirm its location in Flash or RAM.

I can work around the problem by calling multicore_lockout_victim_init () on core 1, and wrapping the Flash write in multicore_lockout_start_blocking () and multicore_lockout_end_blocking (). That results in a noticable interruption to video generation while writing to Flash although it does at least resume once the write to Flash has completed. However if all the pico_scanvideo code is in RAM this should not be necessary.

My code is at https://github.com/Memotech-Bill/BBCSDL

nonesense message in pico_extras_import.cmake

Line 53 has the message;

"PICO EXTRAS location was not specified. Please set PICO_EXTRAS_PATH or set PICO_EXTRAS_FETCH_FROM_GIT to on to fetch from git."
should it really be;

... PICO_EXTRAS_FETCH_FROM_GIT to fetch from git.

usb_stream_helper requires the chunk buffer size to be a power of 2

The asserts in the code indicate that that chunk_size must be a multiple of the usb packet size (64 bytes):

assert(!(chunk_size & 63u)); // buffer should be a multiple of USB packet buffer size

But in reality things break if the chunk_size is not also a power of 2 as the offset computation breaks down here:

return transfer->offset & (transfer->chunk_size - 1);

For example, if the chunk_size is 192 bytes the offset will not be updated after the first packet is sent, and so the first packet gets sent twice.

Pico doesn't wake up properly from Dormant/Sleep

Hi, thanks for providing this library.

I want to use dormant mode to reduce power consumption when not actively processing something. However this has several issues.

When the Pico wakes back up from IRQ it does not restart the clocks that were disabled by sleep_run_from_dormant_source()

I've attempted to re-enable all clocks using the following code, which is based on the recover_from_sleep() function found here. This article is also useful.

// Save existing clock states
uint scb_orig = scb_hw->scr;
uint clock0_orig = clocks_hw->sleep_en0;
uint clock1_orig = clocks_hw->sleep_en1;

// Go to sleep until we see a low level on SLEEP_PIN
sleep_run_from_xosc();    
sleep_goto_dormant_until_pin(SLEEP_PIN, 0, 0);

// Recover from sleep
rosc_write(&rosc_hw->ctrl, ROSC_CTRL_ENABLE_BITS);
scb_hw->scr = scb_orig;
clocks_hw->sleep_en0 = clock0_orig;
clocks_hw->sleep_en1 = clock1_orig;
clocks_init();
stdio_init_all();

While this does get all the clocks back up and running, there are still two issues that I'm aware of:

  1. The Pico cannot communicate via stdio_usb, only via stdio_uart. If UART is needed for purposes other than stdio this is a problem.
  2. The Pico can only enter dormant mode a handful of times before crashing/locking up.

I've looked around a bit to verify that I'm not the only one experiencing this issue.

Include library to generate tones

I would be nice to have a library that generates tones inside the pico-extras.

A lot of people is familiar with the tone() function from Arduino which simplifies a lot the process of including a speaker or buzzer in your projects.

problems compiling lwip module inside pico-extras

Hello,

Not sure if is the right place to report this issue, but i'm having problems to compile lwip lib that is inside pico-extras.

/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/rmiieth.dir/Users/leandro/Projects/pico-extras/lib/lwip/src/core/netif.c.obj: in function `netif_set_addr':
netif.c:(.text.netif_set_addr+0x7e): undefined reference to `acd_netif_ip_addr_changed'
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: netif.c:(.text.netif_set_addr+0xb6): undefined reference to `acd_netif_ip_addr_changed'
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/rmiieth.dir/Users/leandro/Projects/pico-extras/lib/lwip/src/core/timeouts.c.obj:(.rodata.lwip_cyclic_timers+0x2c): undefined reference to `acd_tmr'
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/rmiieth.dir/Users/leandro/Projects/pico-extras/lib/lwip/src/core/ipv4/dhcp.c.obj: in function `dhcp_recv':
dhcp.c:(.text.dhcp_recv+0x416): undefined reference to `acd_start'
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/rmiieth.dir/Users/leandro/Projects/pico-extras/lib/lwip/src/core/ipv4/dhcp.c.obj: in function `dhcp_start':
dhcp.c:(.text.dhcp_start+0x42): undefined reference to `acd_add'
/usr/local/Cellar/arm-none-eabi-gcc/9-2019-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/rmiieth.dir/Users/leandro/Projects/pico-extras/lib/lwip/src/core/ipv4/etharp.c.obj: in function `etharp_input':
etharp.c:(.text.etharp_input+0x72): undefined reference to `acd_arp_reply'
collect2: error: ld returned 1 exit status
make[2]: *** [rmiieth.elf] Error 1
make[1]: *** [CMakeFiles/rmiieth.dir/all] Error 2
make: *** [all] Error 2

The functions are defined inside acd.c but seems like this file is not listed for compilation and thus functions will be missing during linkage.

I'm trying to compile and test this project/repo: https://github.com/strags/pico-rmiieth , out of the box without modification.

OS: Mac OS X 10.15.7 (also tried inside Debian Docker image)
CMake Version: 3.20.2

Thanks in advance!

Regards,
Leandro

scanvideo.c claims fixed resources

scanvideo.c makes claims for fixed hardware resources, specifically PIO0, low numbered DMA channels and low numbered state machines. However these may have already been claimed for other services.

Ideally the code should be modified to use the claim_unused routines.

If that is not possible, at least used fixed high number DMA channels and state machines, which would be the last resources to be claimed by the claim_unused routines.

Schematic or hardware specification for scanvideo.c ?

I see the VGA generator is based on 5:5:5 RGB pixels, but I don't see any details of the video DAC used, or a schematic for one. I assume a resistor based DAC is intended? If so, what resistor values are suitable?

Do the hsync and vsync signals also need resistors? Is there any other circuitry needed besides just resistors?

A simple schematic would be useful. Failing that, just a clear description of how to build it.

On first look, I don't even see how the GPIO pins are assigned, or any obvious documentation about that. I'd presumably need to wade through the code to try to figure it out. A simple table of pin assignments would be a good start.

MQTT keep alive ping is not working for RP2040W (Pico W)

Pico W SDK: 1.4.0
IDE: CLion on Ubuntu 22.04 running on a PC:
GCC: 11.2.0 (Ubuntu 11.2.0-19ubuntu1)
MQTT broker/server: Mosquitto 2.0.15 running on Ubuntu 22.04.

Issue: MQTT keep alive ping is not working for RP2040W (Pico W).
mqtt_cyclic_timer() is never called. It seems that timeouts::sys_timeout() never fires. The keep alive ping is never sent to the server thus causing the server to disconnect the client due to inactivity.

I added additional debugging output in apps/mqtt/mqtt.c to the following two functions:

static err_t mqtt_tcp_connect_cb( void *arg, struct altcp_pcb *tpcb, err_t err )
{
...
  /* Start cyclic timer */
  sys_timeout( MQTT_CYCLIC_TIMER_INTERVAL * 1000, mqtt_cyclic_timer, client );
  client->cyclic_tick = 0;
  LWIP_DEBUGF( MQTT_DEBUG_TRACE, ( "mqtt_tcp_connect_cb: mqtt_cyclic_timer: started\n" ) );
...
}
static void mqtt_cyclic_timer( void *arg )
{
  LWIP_DEBUGF( MQTT_DEBUG_TRACE, ( "mqtt_cyclic_timer: called\n" ) );
...
  if ( restart_timer )
  {
    sys_timeout( MQTT_CYCLIC_TIMER_INTERVAL * 1000, mqtt_cyclic_timer, arg );
    LWIP_DEBUGF( MQTT_DEBUG_TRACE, ( "mqtt_cyclic_timer: restarted\n" ) );
  }
}

I set the keep alive to 15 seconds:

....
  /* Initialize and configure the client info structure */
  struct mqtt_connect_client_info_t clientInfo;
  clientInfo.client_id = MQTT_CLIENT_ID;
  clientInfo.client_user = MQTT_USER;
  clientInfo.client_pass = MQTT_USER_PASSWD;
  clientInfo.keep_alive = 15;
  clientInfo.will_topic = NULL; /* set to NULL if will is not to be used, will_msg, will_qos and will retain are then ignored */
  clientInfo.will_msg = NULL;
  clientInfo.will_qos = 0;
  clientInfo.will_retain = 0;

  err = mqtt_client_connect(
    client,
    &brokerAddr,
    MQTT_PORT,
    mqttConnectionCallback,
    NULL,
    &clientInfo
  );
....

I get the following output when I run a simple MQTT client (built using the MQTT documentation provided) on the PICO W with debug enabled, You will note that the new debug messages added to mqtt_cyclic_timer() never appear.

Version: 7.95.49 (2271bb6 CY) CRC: b7a28ef3 Date: Mon 2021-11-29 22:50:27 PST Ucode Ver: 1043.2162 FWID 01-c51d9400
cyw43 loaded ok, mac 28:cd:c1:04:94:65
API: 12.2
Data: RaspberryPi.PicoW
Compiler: 1.29.4
ClmImport: 1.47.1
Customization: v5 22/06/24
Creation: 2022-06-24 06:55:08
connect status: joining
connect status: no ip
connect status: link up
mqtt_client_connect: Connecting to host: 10.3.17.26 at port:1883
mqtt_tcp_connect_cb: TCP connection established to server
mqtt_tcp_connect_cb: mqtt_cyclic_timer: started <<<<< NOTE THIS ENTRY (added by me)
mqtt_output_send: tcp_sndbuf: 11680 bytes, ringbuf_linear_available: 33, get 0, put 33
mqtt_parse_incoming: Remaining length after fixed header: 2
mqtt_parse_incoming: msg_idx: 4, cpy_len: 2, remaining 0
mqtt_message_received: Connect response code 0
mqtt_sub_unsub: Client (un)subscribe to topic "mqtt/test/in", id: 1
mqtt_output_send: tcp_sndbuf: 11680 bytes, ringbuf_linear_available: 19, get 33, put 52
mqtt_parse_incoming: Remaining length after fixed header: 3
mqtt_parse_incoming: msg_idx: 5, cpy_len: 3, remaining 0
mqtt_message_received: SUBACK response with id 1
mqtt_tcp_recv_cb: Recv pbuf=NULL, remote has closed connection
mqtt_client_connect: Connecting to host: 10.3.17.26 at port:1883
mqtt_tcp_connect_cb: TCP connection established to server
mqtt_tcp_connect_cb: mqtt_cyclic_timer: started <<<<< NOTE THIS ENTRY (added by me)
mqtt_output_send: tcp_sndbuf: 11680 bytes, ringbuf_linear_available: 33, get 0, put 33
mqtt_parse_incoming: Remaining length after fixed header: 2
mqtt_parse_incoming: msg_idx: 4, cpy_len: 2, remaining 0
mqtt_message_received: Connect response code 0
mqtt_sub_unsub: Client (un)subscribe to topic "mqtt/test/in", id: 1
mqtt_output_send: tcp_sndbuf: 11680 bytes, ringbuf_linear_available: 19, get 33, put 52
mqtt_parse_incoming: Remaining length after fixed header: 3
mqtt_parse_incoming: msg_idx: 5, cpy_len: 3, remaining 0
mqtt_message_received: SUBACK response with id 1
mqtt_tcp_recv_cb: Recv pbuf=NULL, remote has closed connection
mqtt_client_connect: Connecting to host: 10.3.17.26 at port:1883
mqtt_tcp_connect_cb: TCP connection established to server
mqtt_tcp_connect_cb: mqtt_cyclic_timer: started <<<<< NOTE THIS ENTRY (added by me)
mqtt_output_send: tcp_sndbuf: 11680 bytes, ringbuf_linear_available: 33, get 0, put 33
mqtt_parse_incoming: Remaining length after fixed header: 2
mqtt_parse_incoming: msg_idx: 4, cpy_len: 2, remaining 0
mqtt_message_received: Connect response code 0
....

The following log messages keep repeating on the Mosquitto broker/server:

1666607350: New connection from 10.3.17.135:52868 on port 1883.
1666607350: New client connected from 10.3.17.135:52868 as picow (p2, c1, k15, u'test').
1666607375: Client picow has exceeded timeout, disconnecting.
1666607380: New connection from 10.3.17.135:52869 on port 1883.
1666607380: New client connected from 10.3.17.135:52869 as picow (p2, c1, k15, u'test').
1666607405: Client picow has exceeded timeout, disconnecting.

"TODO add the encoder here" - add platypus image encoder

It has to exist somewhere, if only to test the decoder:

[platypus](src/common/platypus)| Decoder for a custom image compression format suitable for dithered images (good for RGB555) and suitable for decoding on RP2040 at scanline speeds ... i.e you can easily decode a 320x240 image 60x per second to avoid storing the uncompressed image for scanout video. It gets about 50% compression (but is designed only for 4x4 fixed dithered RGB555 images, so is somewhat specific!). TODO add the encoder here :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.