Skip to content

Merge in 8.2.7 #8494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9acc542
Deinit all the pins.
bill88t Sep 11, 2023
33acd5f
Merge pull request #8393 from bill88t/bp-cam-deinit
jepler Sep 13, 2023
5191071
fixing the wrong rx,tx gpio related issue.
tirtharajsinha Sep 13, 2023
f13edcc
Merge pull request #8396 from tirtharajsinha/8.2.x
dhalbert Sep 13, 2023
18041ea
rgbmatrix: more small doc improvements
jepler Sep 14, 2023
9b20e31
rgbmatrix: also explain the order of rgb and addr pins
jepler Sep 14, 2023
9710ef0
matrixportal_m4: Add board.MTX_ADDRESS and board.MTX_COMMON
jepler Sep 14, 2023
b61900f
fixup! matrixportal_m4: Add board.MTX_ADDRESS and board.MTX_COMMON
jepler Sep 14, 2023
0e78ab6
rgbmatrix: document MTX_ADDRESS and MTX_COMMON
jepler Sep 14, 2023
ee86c76
fix markup, that's not a link
jepler Sep 18, 2023
9e9dff4
Merge pull request #8400 from jepler/update-rgbmatrix-docs
dhalbert Sep 18, 2023
931a6ad
fix CPU on Monster M4SK; turn off audiobusio by default on SAMD51G
dhalbert Sep 18, 2023
40a5313
Merge pull request #8414 from dhalbert/samd51g-fixes
tannewt Sep 19, 2023
8f3c642
Fix MDNS after the user turns off wifi
tannewt Sep 20, 2023
37180b2
Merge pull request #8418 from tannewt/fix_mdns_crash_after_user_disco…
dhalbert Sep 21, 2023
9012e34
Add files via upload
MakerM0 Sep 24, 2023
9d90680
Add board def for MagiClick S3
MakerM0 Sep 24, 2023
f7bc3b8
Merge branch '8.2.x' into magiclick_s3_n4r2
MakerM0 Sep 24, 2023
0bf4f19
Merge pull request #1 from MakerM0/magiclick_s3_n4r2
MakerM0 Sep 24, 2023
a5ae99a
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
12f35d1
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
6d7a08b
Update board.c
MakerM0 Sep 24, 2023
6f77f0f
Update mpconfigboard.h
MakerM0 Sep 24, 2023
9ab8822
Update pins.c
MakerM0 Sep 24, 2023
ab8e119
Update sdkconfig
MakerM0 Sep 24, 2023
5ffb7e7
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
0507e7a
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
c35839a
Update board.c
MakerM0 Sep 24, 2023
3913adf
Update sdkconfig
MakerM0 Sep 24, 2023
918f93f
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
71e165b
Update pins.c
MakerM0 Sep 24, 2023
ca4ecf0
Update board.c
MakerM0 Sep 24, 2023
1143d3e
Update mpconfigboard.h
MakerM0 Sep 24, 2023
e197493
Update mpconfigboard.mk
MakerM0 Sep 24, 2023
9284d25
Update pins.c
MakerM0 Sep 24, 2023
6acce76
Update pins.c
MakerM0 Sep 24, 2023
761ac3b
Update pins.c
MakerM0 Sep 24, 2023
586ead3
Merge pull request #8427 from MakerM0/8.2.x
dhalbert Sep 24, 2023
f5d4f1e
Fixed displayio/Bitmap value_count range
rimwolf-redux Sep 26, 2023
41096dd
Merge pull request #8434 from rimwolf-redux/bitmap
jepler Sep 27, 2023
79161db
Update sdkconfig
MakerM0 Sep 29, 2023
7aa8535
Update mpconfigboard.mk
MakerM0 Sep 29, 2023
4c21f22
Improve RGBMatrix allocation tracking
tannewt Sep 29, 2023
73292f6
Merge pull request #8445 from MakerM0/8.2.x
tannewt Sep 29, 2023
5327487
Merge pull request #8446 from tannewt/rgbmatrix_memory_fix
dhalbert Sep 30, 2023
2e6ef78
Update Metro S3 pin mapping for Rev B
tannewt Oct 4, 2023
d4b5146
Adding the missing pins(33,34) and SPI pins
tirtharajsinha Oct 7, 2023
a14a9a0
Merge pull request #8463 from tirtharajsinha/8.2.x
dhalbert Oct 7, 2023
c8926de
removing gpio 19 and 20 as these pins are not broken out in board
tirtharajsinha Oct 7, 2023
2047a8d
Merge branch 'adafruit:8.2.x' into 8.2.x
tirtharajsinha Oct 8, 2023
cc709f6
Merge pull request #8465 from tirtharajsinha/8.2.x
tannewt Oct 10, 2023
56d5df3
Copy non touch, change name, pid and lcd rest pin.
minordemon Oct 11, 2023
2de11f0
Merge pull request #8459 from tannewt/metro_s3_revb
tannewt Oct 12, 2023
e576782
Merge pull request #8475 from minordemon/Waveshare-RP2040-Touch-LCD-1_28
tannewt Oct 12, 2023
4606af4
Added Unexpected Maker BlizzardS3 board for Espressif port.
UnexpectedMaker Oct 15, 2023
10a4424
Merge pull request #8480 from UnexpectedCircuitPython/um_blizzard_s3
dhalbert Oct 15, 2023
89467ec
Merge tag '8.2.7' into merge_in_8.2.7
tannewt Oct 20, 2023
c988ff7
Remove random A
tannewt Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ports/espressif/boards/adafruit_matrixportal_s3/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ STATIC const mp_rom_obj_tuple_t matrix_addr_tuple = {
{&mp_type_tuple},
5,
{
MP_ROM_PTR(&pin_GPIO35),
MP_ROM_PTR(&pin_GPIO45),
MP_ROM_PTR(&pin_GPIO36),
MP_ROM_PTR(&pin_GPIO48),
MP_ROM_PTR(&pin_GPIO45),
MP_ROM_PTR(&pin_GPIO35),
MP_ROM_PTR(&pin_GPIO21),
}
};
Expand Down
3 changes: 3 additions & 0 deletions ports/espressif/common-hal/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ void common_hal_rgbmatrix_timer_enable(void *ptr) {
}

void common_hal_rgbmatrix_timer_disable(void *ptr) {
if (ptr == NULL) {
return;
}
timer_index_t *timer = (timer_index_t *)ptr;
if (timer->idx == TIMER_MAX) {
return;
Expand Down
6 changes: 2 additions & 4 deletions shared-bindings/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ STATIC const mp_rom_map_elem_t rgbmatrix_rgbmatrix_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(rgbmatrix_rgbmatrix_locals_dict, rgbmatrix_rgbmatrix_locals_dict_table);

STATIC void rgbmatrix_rgbmatrix_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) {
rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in;

*bufinfo = self->bufinfo;
common_hal_rgbmatrix_rgbmatrix_get_bufinfo(self_in, bufinfo);
}

// These version exists so that the prototype matches the protocol,
Expand Down Expand Up @@ -442,7 +440,7 @@ STATIC mp_int_t rgbmatrix_rgbmatrix_get_buffer(mp_obj_t self_in, mp_buffer_info_
if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) {
return 1;
}
*bufinfo = self->bufinfo;
common_hal_rgbmatrix_rgbmatrix_get_bufinfo(self_in, bufinfo);
bufinfo->typecode = 'H';
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions shared-bindings/rgbmatrix/RGBMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type;
void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void *timer);
void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t *);
void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t *);
void common_hal_rgbmatrix_rgbmatrix_get_bufinfo(rgbmatrix_rgbmatrix_obj_t *self, mp_buffer_info_t *bufinfo);
void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self);
void common_hal_rgbmatrix_rgbmatrix_set_paused(rgbmatrix_rgbmatrix_obj_t *self, bool paused);
bool common_hal_rgbmatrix_rgbmatrix_get_paused(rgbmatrix_rgbmatrix_obj_t *self);
Expand Down
72 changes: 59 additions & 13 deletions shared-module/rgbmatrix/RGBMatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ STATIC void common_hal_rgbmatrix_rgbmatrix_construct1(rgbmatrix_rgbmatrix_obj_t
}
// verify that the matrix is big enough
mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize - 1), false);
self->allocation = NULL;
} else {
self->bufinfo.buf = common_hal_rgbmatrix_allocator_impl(self->bufsize);
// The supervisor allocation can move memory by changing self->allocation->ptr.
// So we hold onto it and update bufinfo every time we use it.
self->allocation = allocate_memory(align32_size(self->bufsize), false, true);
self->bufinfo.buf = self->allocation->ptr;
self->bufinfo.len = self->bufsize;
self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW;
}
Expand Down Expand Up @@ -146,7 +150,9 @@ STATIC void free_pin_seq(uint8_t *seq, int count) {

extern int pm_row_count;
STATIC void common_hal_rgbmatrix_rgbmatrix_deinit1(rgbmatrix_rgbmatrix_obj_t *self) {
common_hal_rgbmatrix_timer_disable(self->timer);
if (self->timer != NULL) {
common_hal_rgbmatrix_timer_disable(self->timer);
}

if (_PM_protoPtr == &self->protomatter) {
_PM_protoPtr = NULL;
Expand All @@ -160,15 +166,15 @@ STATIC void common_hal_rgbmatrix_rgbmatrix_deinit1(rgbmatrix_rgbmatrix_obj_t *se

// If it was supervisor-allocated, it is supervisor-freed and the pointer
// is zeroed, otherwise the pointer is just zeroed
if (self->bufinfo.buf) {
common_hal_rgbmatrix_free_impl(self->bufinfo.buf);
self->bufinfo.buf = NULL;
if (self->allocation != NULL) {
free_memory(self->allocation);
}


// If a framebuffer was passed in to the constructor, clear the reference
// here so that it will become GC'able
self->framebuffer = mp_const_none;

self->bufinfo.buf = NULL;
}

void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t *self) {
Expand All @@ -187,6 +193,13 @@ void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t *self) {
self->base.type = &mp_type_NoneType;
}

void common_hal_rgbmatrix_rgbmatrix_get_bufinfo(rgbmatrix_rgbmatrix_obj_t *self, mp_buffer_info_t *bufinfo) {
if (self->allocation != NULL) {
self->bufinfo.buf = self->allocation->ptr;
}
*bufinfo = self->bufinfo;
}

void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self) {
if (self->framebuffer != mp_const_none) {
memset(&self->bufinfo, 0, sizeof(self->bufinfo));
Expand All @@ -196,11 +209,6 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self)
common_hal_rgbmatrix_rgbmatrix_deinit1(self);
common_hal_rgbmatrix_rgbmatrix_construct1(self, mp_const_none);
#endif
if (self->bufinfo.buf == NULL) {
self->bufinfo.buf = common_hal_rgbmatrix_allocator_impl(self->bufsize);
self->bufinfo.len = self->bufsize;
self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW;
}
memset(self->bufinfo.buf, 0, self->bufinfo.len);
common_hal_rgbmatrix_rgbmatrix_set_paused(self, false);
}
Expand All @@ -214,6 +222,9 @@ void common_hal_rgbmatrix_rgbmatrix_set_paused(rgbmatrix_rgbmatrix_obj_t *self,
_PM_stop(&self->protomatter);
} else if (!paused && self->paused) {
_PM_resume(&self->protomatter);
if (self->allocation) {
self->bufinfo.buf = self->allocation->ptr;
}
_PM_convert_565(&self->protomatter, self->bufinfo.buf, self->width);
_PM_swapbuffer_maybe(&self->protomatter);
}
Expand All @@ -226,6 +237,9 @@ bool common_hal_rgbmatrix_rgbmatrix_get_paused(rgbmatrix_rgbmatrix_obj_t *self)

void common_hal_rgbmatrix_rgbmatrix_refresh(rgbmatrix_rgbmatrix_obj_t *self) {
if (!self->paused) {
if (self->allocation != NULL) {
self->bufinfo.buf = self->allocation->ptr;
}
_PM_convert_565(&self->protomatter, self->bufinfo.buf, self->width);
_PM_swapbuffer_maybe(&self->protomatter);
}
Expand All @@ -240,11 +254,43 @@ int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t *self) {
return computed_height;
}

// Track the returned pointers and their matching allocation so that we can free
// them even when the memory was moved by the supervisor. This prevents leaks
// but doesn't protect against the memory being used after its been freed! The
// long term fix is to utilize a permanent heap that can be shared with MP's
// split heap.
typedef struct matrix_allocation {
void *original_pointer;
supervisor_allocation *allocation;
} matrix_allocation_t;

// Four should be more than we ever need. ProtoMatter does 3 allocations currently.
static matrix_allocation_t allocations[4];

void *common_hal_rgbmatrix_allocator_impl(size_t sz) {
supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true);
return allocation ? allocation->ptr : NULL;
if (allocation == NULL) {
return NULL;
}
for (size_t i = 0; i < sizeof(allocations); i++) {
matrix_allocation_t *matrix_allocation = &allocations[i];
if (matrix_allocation->original_pointer == NULL) {
matrix_allocation->original_pointer = allocation->ptr;
matrix_allocation->allocation = allocation;
return allocation->ptr;
}
}
return NULL;
}

void common_hal_rgbmatrix_free_impl(void *ptr_in) {
free_memory(allocation_from_ptr(ptr_in));
for (size_t i = 0; i < sizeof(allocations); i++) {
matrix_allocation_t *matrix_allocation = &allocations[i];
if (matrix_allocation->original_pointer == ptr_in) {
matrix_allocation->original_pointer = NULL;
free_memory(matrix_allocation->allocation);
matrix_allocation->allocation = NULL;
return;
}
}
}
2 changes: 2 additions & 0 deletions shared-module/rgbmatrix/RGBMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@

#include "py/obj.h"
#include "lib/protomatter/src/core.h"
#include "supervisor/memory.h"

extern const mp_obj_type_t rgbmatrix_RGBMatrix_type;
typedef struct {
mp_obj_base_t base;
mp_obj_t framebuffer;
mp_buffer_info_t bufinfo;
supervisor_allocation *allocation;
Protomatter_core protomatter;
void *timer;
uint16_t bufsize, width;
Expand Down