Day 1 Tables and Badges

Hello Ziguanas! :ziggy: (and Roc folks too :)) Tons of people (especially the awesome @mattnite) have been hard at work getting the SYCL Badge ready for tomorrow. Come find out what all the hype is all about while hanging out with and meeting a bunch of cool peeps! We'll be working on the badge all day, though it's not a hard and fast thing (you can do other things or not even touch your badge if you want, no pressure!) See you soon!! 🫡
414 Replies
mlugg
mlugg10mo ago
@aurame help the simulator does not work Watcher not found. on both firefox and chromium
captainhorst
captainhorst10mo ago
I use an extension to disable CORS in Chrome. Not sure if this is the intended way. 😅
not_motiejus
not_motiejus10mo ago
@JerwuQu | Marcus Ramse suggested a workaround:
zig build
zig build watch
zig build
zig build watch
and then refresh the web page
aurame
aurameOP10mo ago
that is not the solution, sorry; bug in build logic i have a PR open to fix it
JerwuQu
JerwuQu10mo ago
Yes, the watcher only builds when files change. You have to do a zig build first
aurame
aurameOP10mo ago
btw y'all, please read https://github.com/ZigEmbeddedGroup/sycl-badge/blob/main/docs/introduction/README.md :) it explains where the badge is at right now
captainhorst
captainhorst10mo ago
Fetch API cannot load http://localhost:2468/cart.wasm due to access control checks. This was the error I was working around
Mitchell Kember
Mitchell Kember10mo ago
btw I found badgesim.microzig.tech works on chrome but not safari
mlugg
mlugg10mo ago
2MB flash separate from the microcontroller's flash
2.6M zig1.wasm
hmmmmmmm..........
frammaa
frammaa10mo ago
only the first 2MB matter 😛
andrewrk
andrewrk10mo ago
MOVE FAST AND BRICK THINGS
widlarizer
widlarizer10mo ago
Where the readme says "the badge is still being worked on" who is working on it? I wanna work in it :zigfix:
mattnite
mattnite10mo ago
@Emil (widlarizer) I am, I spent all the time on the hardware, had some personal stuff happen and didn't have enough time to get the firmware fully set up
widlarizer
widlarizer10mo ago
hi Matt! But you're not here right, is there any way to collab? Any starting point to go play around with a peripheral that's missing support?
mattnite
mattnite10mo ago
I'm just about to merge a codegen bugfix, once I'm done that I have some peripherals I could use some help with
mlugg
mlugg10mo ago
i hope you're merging a bug fix not a bug otherwise it sounds like we're going backwards somewhat
mattnite
mattnite10mo ago
ty
widlarizer
widlarizer10mo ago
Got it
aurame
aurameOP10mo ago
:wheeze:
widlarizer
widlarizer10mo ago
Well you're not running wasm on the board right :monkaS:
JerwuQu
JerwuQu10mo ago
nobody is stopping you...
mlugg
mlugg10mo ago
why not? wasm interpreter :)
andrewrk
andrewrk10mo ago
YO if anyone is having trouble cloning the repo, I have it on a flash drive, come get it from me
123_javla
123_javla10mo ago
I'm having trouble loading the nix environment error: Package ‘gdb-13.2’ in /nix/store/81d6lv96pws78iijmmsra5ql8wxgb1cb-nixpkgs/nixpkgs/pkgs/development/tools/misc/gdb/default.nix:143 is not available on the requested hostPlatform: hostPlatform.config = "aarch64-apple-darwin" package.meta.platforms = [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "loongarch64-linux" "m68k-linux" "microblaze-linux" "microblazeel-linux" "mips-linux" "mips64-linux" "mips64el-linux" "mipsel-linux" "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux" "s390x-linux" "x86_64-linux" "i686-cygwin" "x86_64-cygwin" "x86_64-darwin"
Snektron
Snektron10mo ago
you wont need that, just comment it out actually you dont need anything from the nix env, just make sure that you have zig 0.12
mattnite
mattnite10mo ago
@Emil (widlarizer) could you work with @slimsag to get a sound system going?
JerwuQu
JerwuQu10mo ago
yea the nix.shell is outdated
mattnite
mattnite10mo ago
There's an example one that @jacobly made under the old demo setup src/cart.zig and its the tone() function
widlarizer
widlarizer10mo ago
right after this lightning talk I'll check out the related code while I'm at it
mattnite
mattnite10mo ago
awesome, thanks
widlarizer
widlarizer10mo ago
is there an experiment branch
mattnite
mattnite10mo ago
I'm currently working on badge-lcd but besides that, main is the closest thing since we're flying by the seat of our pants
Snektron
Snektron10mo ago
matt trying to save the badge rn
mattnite
mattnite10mo ago
yes
Snektron
Snektron10mo ago
is src/lcd.zig or src/board/lcd.zig the good one
andrewrk
andrewrk10mo ago
robin asking the real questions
widlarizer
widlarizer10mo ago
how do I run things in src/badge/demos/ :KRRemHmmm: nvm it's in zig-out/firmware/badge.demo.audio.elf and uf2
JerwuQu
JerwuQu10mo ago
so audio works on the board right now?
andrewrk
andrewrk10mo ago
this one did nothing on my badge
aurame
aurameOP10mo ago
i don't believe so?
JerwuQu
JerwuQu10mo ago
okay! unfortunately forgot to bring my cool midi files, otherwise i could've had an audio demo when it's working my wasm4 music converter should work for the badge too if the badge framerate is stable enough
andrewrk
andrewrk10mo ago
I have a QOA implementation in zig
aurame
aurameOP10mo ago
unfortunately you can't play pcm with the api
JerwuQu
JerwuQu10mo ago
👀 would be cool! the cart api currently only has a tone, not real pcm
aurame
aurameOP10mo ago
you can hack around it though if you'd like :P
JerwuQu
JerwuQu10mo ago
excited to hear the badge buzzer speaker version of the hit single "brick your badge"
mattnite
mattnite10mo ago
src/board/lcd.zig
widlarizer
widlarizer10mo ago
audio demo doesn't work probably bc the timer is borked gclk
Snektron
Snektron10mo ago
probably the problem with the lcd too
JerwuQu
JerwuQu10mo ago
we don't have a clock?
mattnite
mattnite10mo ago
audio stopped working because I tried to clean up some of the clock logic
JerwuQu
JerwuQu10mo ago
ah
mattnite
mattnite10mo ago
I'll have the fix in a couple min
widlarizer
widlarizer10mo ago
is src/audio.zig used in the sim?
frammaa
frammaa10mo ago
hey, the cart api doesn't expose the an update function, so I'm guessing I just assume it's being called every so often and roll with it, is that right? basically I memcpy into the pub variables exposed in the cart api and eventually stuff will appear on screen?
mattnite
mattnite10mo ago
no that's used by the old code, everything we're using is under src/badge/ for the most part -- and to be clear there's no audio system set up in the badge That's the idea but the firmware is being worked on as we speak
widlarizer
widlarizer10mo ago
in src/cart.zig you do have pub fn tick() void it writes from FRAMEBUFFER to lcd.fb
mattnite
mattnite10mo ago
I'm going to do some quick cleanup so it's more obvious what's old and what's not
andrewrk
andrewrk10mo ago
nice!
Bjorn
Bjorn10mo ago
if it hasn't been mentioned, you can cart.trace("foobar") and then in the simulator you can open up the console in your browser and see your trace statements there
widlarizer
widlarizer10mo ago
oh ok
No description
Snektron
Snektron10mo ago
const std = @import("std");
const microzig = @import("microzig");

const hal = microzig.hal;
const mclk = hal.clocks.mclk;
const gclk = hal.clocks.gclk;
const sercom = hal.sercom;
const port = hal.port;
const timer = hal.timer;

const board = microzig.board;
const tft_rst_pin = board.TFT_RST;
const tft_lite_pin = board.TFT_LITE;
const tft_dc_pin = board.TFT_DC;
const tft_cs_pin = board.TFT_CS;
const tft_sck_pin = board.TFT_SCK;
const tft_mosi_pin = board.TFT_MOSI;

var fb: [board.lcd.width][board.lcd.height]board.lcd.Color16 = undefined;

const red16 = board.lcd.red16;

pub fn main() !void {
mclk.set_apb_mask(.{
.SERCOM4 = .enabled,
.TC0 = .enabled,
.TC1 = .enabled,
});

gclk.enable_generator(.GCLK1, .DFLL, .{
.divsel = .DIV1,
.div = 48,
});

gclk.set_peripheral_clk_gen(.GCLK_TC0_TC1, .GCLK1);
gclk.set_peripheral_clk_gen(.GCLK_SERCOM4_CORE, .GCLK0);

timer.init();
var lcd = board.lcd.Lcd.init(.{
.spi = sercom.spi.Master.init(.SERCOM4, .{
.cpha = .LEADING_EDGE,
.cpol = .IDLE_LOW,
.dord = .MSB,
.dopo = .PAD2,
.ref_freq_hz = 48_000_000,
.baud_freq_hz = 4_000_000,
}),
.pins = .{
.rst = tft_rst_pin,
.lite = tft_lite_pin,
.dc = tft_dc_pin,
.cs = tft_cs_pin,
.sck = tft_sck_pin,
.mosi = tft_mosi_pin,
},
.fb = .{
.bpp16 = &fb,
},
});

lcd.clear_screen(red16);
lcd.set_window(0, 0, 10, 10);

timer.delay_us(5 * std.time.us_per_s);
lcd.invert();
while (true) {}
}
const std = @import("std");
const microzig = @import("microzig");

const hal = microzig.hal;
const mclk = hal.clocks.mclk;
const gclk = hal.clocks.gclk;
const sercom = hal.sercom;
const port = hal.port;
const timer = hal.timer;

const board = microzig.board;
const tft_rst_pin = board.TFT_RST;
const tft_lite_pin = board.TFT_LITE;
const tft_dc_pin = board.TFT_DC;
const tft_cs_pin = board.TFT_CS;
const tft_sck_pin = board.TFT_SCK;
const tft_mosi_pin = board.TFT_MOSI;

var fb: [board.lcd.width][board.lcd.height]board.lcd.Color16 = undefined;

const red16 = board.lcd.red16;

pub fn main() !void {
mclk.set_apb_mask(.{
.SERCOM4 = .enabled,
.TC0 = .enabled,
.TC1 = .enabled,
});

gclk.enable_generator(.GCLK1, .DFLL, .{
.divsel = .DIV1,
.div = 48,
});

gclk.set_peripheral_clk_gen(.GCLK_TC0_TC1, .GCLK1);
gclk.set_peripheral_clk_gen(.GCLK_SERCOM4_CORE, .GCLK0);

timer.init();
var lcd = board.lcd.Lcd.init(.{
.spi = sercom.spi.Master.init(.SERCOM4, .{
.cpha = .LEADING_EDGE,
.cpol = .IDLE_LOW,
.dord = .MSB,
.dopo = .PAD2,
.ref_freq_hz = 48_000_000,
.baud_freq_hz = 4_000_000,
}),
.pins = .{
.rst = tft_rst_pin,
.lite = tft_lite_pin,
.dc = tft_dc_pin,
.cs = tft_cs_pin,
.sck = tft_sck_pin,
.mosi = tft_mosi_pin,
},
.fb = .{
.bpp16 = &fb,
},
});

lcd.clear_screen(red16);
lcd.set_window(0, 0, 10, 10);

timer.delay_us(5 * std.time.us_per_s);
lcd.invert();
while (true) {}
}
lcd demo ish the color isnt right
widlarizer
widlarizer10mo ago
What is the intended architecture for audio? My guess: in the main loop, do the synthesis for all your channels to feed a sample buffer. That buffer feeds a DMA into the DAC
jacobly
jacobly10mo ago
I ported the old audio code except dma so far I do synthesis as the buffer empties regardless of the main loop
mattnite
mattnite10mo ago
oh sweet, nvm @Emil (widlarizer) , one thing I could use another pair of eyes on is why the button state isn't updating
jacobly
jacobly10mo ago
the lcd branch doesn't contain the microzig update last I checked
widlarizer
widlarizer10mo ago
you do synthesis in an interrupt handler?
jacobly
jacobly10mo ago
yep
mattnite
mattnite10mo ago
I've been rebasing, I'll push
widlarizer
widlarizer10mo ago
aye. How can I repro?
mattnite
mattnite10mo ago
For the neopixels demo, when you press A the colors should change
jacobly
jacobly10mo ago
cause I moved the neopixels from start to update and the buttons work fine well lol you meant that
mattnite
mattnite10mo ago
:facepalm:
widlarizer
widlarizer10mo ago
:dennis: is this functional? on some branch?
mattnite
mattnite10mo ago
I think it's on the jacob branch
widlarizer
widlarizer10mo ago
doesn't seem to be judging by git log --stat
mattnite
mattnite10mo ago
I just want to say that I really appreciate everyone pitching in and making this work I think the LCD isn't working because the mux isn't set for the pins, though I'm not sure why @Robin was able to see incorrect colors
jacobly
jacobly10mo ago
the bootloader may have happened to leave the mux "correct"
emidoots
emidoots10mo ago
@aurame the emulator sound support is wonky for me, got a sec? orr maybe not, I'm not sure lol
widlarizer
widlarizer10mo ago
@Robin how do you run the demo you sent? On main, when I put it into src/badges/demos/robin.zig and do
--- a/build.zig
+++ b/build.zig
@@ -84,6 +84,7 @@ pub fn build(b: *Build) void {
//"qspi",
//"qa",
//"clocks",
+ "robin",
--- a/build.zig
+++ b/build.zig
@@ -84,6 +84,7 @@ pub fn build(b: *Build) void {
//"qspi",
//"qa",
//"clocks",
+ "robin",
I get src/badge/demos/robin.zig:39:21: error: root struct of file 'board' has no member named 'lcd'
Neofoxx
Neofoxx10mo ago
The LEDs don't work if you flash the board. Signal looks a bit "off"
No description
widlarizer
widlarizer10mo ago
They worked for me. Where did you even connect your logic analyzer? Which demo is this?
jacobly
jacobly10mo ago
ported dma, but not sure how we hook to api calls in the current state there's so many copies of things and I don't know what's active
widlarizer
widlarizer10mo ago
can I take a look?
jacobly
jacobly10mo ago
it's on jacob well my git add didn't go through
aurame
aurameOP10mo ago
you need to click on the page once
mattnite
mattnite10mo ago
Sorry! I had no idea why things weren't working on your image, the easiest thing for me was to move things over bit by bit
emidoots
emidoots10mo ago
I think maybe it's something like "if the zig build fails, the watcher dies in a really weird way and restarting it doesn't bring audio back all the time" - maybe I need to click though yeah
JerwuQu
JerwuQu10mo ago
yeah, you need to interact to let the browser know you trust the website :)
jacobly
jacobly10mo ago
I mean you probably only had to delete the usb code lol remember I didn't have a debugger yet so it looped waiting for usb commands
mholub
mholub10mo ago
is there some way to slow down the execution, something like sleep function? 🙂 or timer?
jacobly
jacobly10mo ago
you can just not do anything for the next n calls to update
Platy
Platy10mo ago
The real solution is to implement a systick on a timer interrupt. That just calls Tick++
mholub
mholub10mo ago
not doing anything is ok for my case 🙂 thanks
mattnite
mattnite10mo ago
once we get consistent timing for frames @mholub you'll be able to count ticks reliably for timing
widlarizer
widlarizer10mo ago
Can't figure out how to build the audio code @jacobly ported
Snektron
Snektron10mo ago
I basically got it to turn on, its white only
widlarizer
widlarizer10mo ago
currently facing a linker script issue with the way I try to use it
Neofoxx
Neofoxx10mo ago
Input pin of the first LED (neopixel/ws2812b) It's the docs/introduction one, reduced to background fill and setting the LEDs
Snektron
Snektron10mo ago
I thought that would be wrong colors but it just doesnt work properly I had to change some stuff in hal to make it work
Snektron
Snektron10mo ago
jacobly
jacobly10mo ago
init builds now
frammaa
frammaa10mo ago
can't really get it to draw a rectangle, this is my attempt:
cart.rect(.{
.x = @intCast(cart.screen_width / 2),
.y = @intCast(cart.screen_height / 2),
.width = 20,
.height = 20,
.stroke_color = .{ .r = 31, .g = 63, .b = 31 },
.fill_color = .{ .r = 31, .g = 63, .b = 31 },
});
cart.rect(.{
.x = @intCast(cart.screen_width / 2),
.y = @intCast(cart.screen_height / 2),
.width = 20,
.height = 20,
.stroke_color = .{ .r = 31, .g = 63, .b = 31 },
.fill_color = .{ .r = 31, .g = 63, .b = 31 },
});
nvm the hotreloading wasn't working right
Iridescent Rose
Iridescent Rose10mo ago
Conversely can I overclock it?
Iridescent Rose
Iridescent Rose10mo ago
The rays need to go faster 😛
No description
mattnite
mattnite10mo ago
ah that's probably just the backlight turning on
krig
krig10mo ago
mholub
mholub10mo ago
have you tried running it on hardware already?
Iridescent Rose
Iridescent Rose10mo ago
idk if LCD is working / if the firmware works and doesn't brick
mattnite
mattnite10mo ago
hey quick question, I keep on hearing people mention bricking their badges, is that actually happening? like if you double press the reset button it won't start the bootloader?
Iridescent Rose
Iridescent Rose10mo ago
I'm not really certain; I'm just following the instructions under the presumption they're right
No description
widlarizer
widlarizer10mo ago
wdym by init
mattnite
mattnite10mo ago
This is correct We're slowly making progress over here
Iridescent Rose
Iridescent Rose10mo ago
I tried flashing, was able to get back to bootloader so I don't think it's hard-brickable (?)
mattnite
mattnite10mo ago
The bootloader is good at not overwriting itself, the only hard brick you'll see is if a program uses the non-volatile memory controller to alter the bootloader
Kiryl
Kiryl10mo ago
I'm not sure if it was discussed already. when I try to copy anything to the badge - it seems to reboot but doesn't work properly. the display is black and only leds with different colors are active
Iridescent Rose
Iridescent Rose10mo ago
Yeah that seems consistent with the instructions
JerwuQu
JerwuQu10mo ago
This is expected
jacobly
jacobly10mo ago
ported a demo, but dac not working yet
mattnite
mattnite10mo ago
if you want a short circuit, you could only do square waves and just use the digital output
widlarizer
widlarizer10mo ago
audio.init() would break a simple demo building for me as of ab543f6e847314d82156d12748290ab0576e767b but that is not latest currently checking out your new audio demo why can't we use add_firmware for your demo to get microzig? I assume there's some difference between a cart and not-a-cart I wanted to check whether the update loop of the 07a8677d src/badge/demos/audio.zig is actually running or whether it gets stuck somewhere but I can't stick an LED toggle in there
mattnite
mattnite10mo ago
@Emil (widlarizer) carts were supposed to be sandboxed but to save time and effort they've just become statically linked libraries
widlarizer
widlarizer10mo ago
can I have microzig available in a cart?
jacobly
jacobly10mo ago
alright I've now hit the unimplemented cart api lol
mattnite
mattnite10mo ago
not having it helps people from shooting themselves in the foot, what reason do you need it?
widlarizer
widlarizer10mo ago
guys link your badge repos if you've got cool stuff running in the emulator, I've heard about @marler8997 👀 ok I think the real issue isn't missing microzig but stuff in the cart API then which is under construction, should I try and add that?
mattnite
mattnite10mo ago
Yes that would be great!
jacobly
jacobly10mo ago
I'm resurrecting the sandbox because the api depends on it lol
mattnite
mattnite10mo ago
I'm all for it, we eventually want sandboxing anyways Yes this would be great, the old cart api used a different structure for the framebuffer, so we need the different functions ported to the new one
jacobly
jacobly10mo ago
ok it's building already, I'm concerned
Snektron
Snektron10mo ago
Is there a way to get debug output from the badge (that is not done by blinking the led)?
andrewrk
andrewrk10mo ago
what does this mean?
No description
jacobly
jacobly10mo ago
my speaker just made the sound it makes when debugging an audio program
JerwuQu
JerwuQu10mo ago
haha! interesting one is there anything in the browser console? the ear-deafening kind?
jacobly
jacobly10mo ago
no just a swoosh but it means it's close to working
widlarizer
widlarizer10mo ago
you mean like blit vs blit16 ?
jacobly
jacobly10mo ago
no the old one is a wasm4 compatible buffer so 4bpp or whatever
andrewrk
andrewrk10mo ago
nope it's gone now 🤷‍♂️
JerwuQu
JerwuQu10mo ago
:itisamystery:
andrewrk
andrewrk10mo ago
does lcd work now?
widlarizer
widlarizer10mo ago
can't find any remnants of that beyond an unused variable :pausers:
jacobly
jacobly10mo ago
dammit @marler8997 using all my ram
marler8997
marler899710mo ago
I upstreamed mine into the samples directory: https://github.com/ZigEmbeddedGroup/sycl-badge/tree/main/samples/blobs run "zig build watch-blobs" to run it in the simulator
GitHub
sycl-badge/samples/blobs at main · ZigEmbeddedGroup/sycl-badge
MicroZig running on the PyBadge! https://badgesim.microzig.tech/ - ZigEmbeddedGroup/sycl-badge
marler8997
marler899710mo ago
we could probably remove the startlogo?
jacobly
jacobly10mo ago
I already gave in to your demands the real issue was moving the framebuffer from runtime ram to cart ram
andrewrk
andrewrk10mo ago
not yet it looks like
jacobly
jacobly10mo ago
oh god it's buzzing
mattnite
mattnite10mo ago
@marler8997 is pair programming with me rn on the LCD
jacobly
jacobly10mo ago
oh wait that was the working audio demo, don't mind me
JerwuQu
JerwuQu10mo ago
the audio demo is working now?
jacobly
jacobly10mo ago
the non-demo audio demo lol if I line step instead of instruction step it swooshes every time
Agni
Agni10mo ago
it has audio?!
jacobly
jacobly10mo ago
it sure is trying
Agni
Agni10mo ago
that unlocked a new dimension for my project
jacobly
jacobly10mo ago
yoo, I'm in a service call! not sure how, everything before that is broken
mattnite
mattnite10mo ago
okay so I got communication working with the LCD I think some rotation stuff is mixed up, or there's a place where width/height coordinates are flipped thought it might be fun for people to try this out
jacobly
jacobly10mo ago
that's MADCTL
mattnite
mattnite10mo ago
no you're MAD
jacobly
jacobly10mo ago
my badge just made an awful sound and then crashed
mattnite
mattnite10mo ago
hell yeah
jacobly
jacobly10mo ago
uhh, I think it's playing the sound... a bit too fast like 15 seconds of music in under a second
mholub
mholub10mo ago
does it mean lcd works if we pull or not yet?
jacobly
jacobly10mo ago
does the rate limiter not work yet?
mattnite
mattnite10mo ago
not yet
jacobly
jacobly10mo ago
I'll fake it for now then
mattnite
mattnite10mo ago
haven't fully tested the LCD out yet
mif
mif10mo ago
Does neopixels actually work for anyone? I do
cart.neopixels.* = .{
.{ .r = 255, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
};
cart.neopixels.* = .{
.{ .r = 255, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
.{ .r = 0, .g = 0, .b = 0 },
};
and it's one green (not red) light in simulator and ~rainbow on the actual badge.
aurame
aurameOP10mo ago
Seems like a flipped some values on the sim, can fix or you can hunt it down For the badge, it seems broken in release small Change to debug and it will no longer be rainbow
jacobly
jacobly10mo ago
yeah the inline asm is broken in non-debug fixing now
widlarizer
widlarizer10mo ago
Classic case
mattnite
mattnite10mo ago
is it something I did or some compiler weirdness?
jacobly
jacobly10mo ago
I failed to notice you did something bad
mattnite
mattnite10mo ago
lmao
jacobly
jacobly10mo ago
it's not even subtle
mattnite
mattnite10mo ago
what was it?
jacobly
jacobly10mo ago
you used labels not allowed
mattnite
mattnite10mo ago
-_-
JerwuQu
JerwuQu10mo ago
how come?
mattnite
mattnite10mo ago
how are you supposed to write assembly without labels?
jacobly
jacobly10mo ago
badly can someone test if 5dcca93c53d4d3e65b369847985896a24725deaa fixes the problem?
widlarizer
widlarizer10mo ago
👀 which problem
jacobly
jacobly10mo ago
release + neopixel
widlarizer
widlarizer10mo ago
(I was at lunch) ok will test it glows as expected
jacobly
jacobly10mo ago
@aurame simulator needs updating for the NeopixelColor change to fix this
and it's one green (not red) light in simulator
widlarizer
widlarizer10mo ago
neopixels doesn't seem to react to A button :/ is that the bug that was supposed to be fixed?
jacobly
jacobly10mo ago
on my commit it should work
widlarizer
widlarizer10mo ago
this is at 5dcca93c zig build +release
jacobly
jacobly10mo ago
actually someone messed up the memory layout on main these addresses are extremely specific lol I think bss now overlaps the stack? idk the hex is hurting my brain
aurame
aurameOP10mo ago
Yeah ik Did y’all inverse it?
jacobly
jacobly10mo ago
rotated more like maybe main is fine
widlarizer
widlarizer10mo ago
you mean the 0xA01E byte size of cart_fixed?
jacobly
jacobly10mo ago
that's right
widlarizer
widlarizer10mo ago
No clue where exactly it's coming from. Some kind of ahead of time reserved thing. @mattnite :stare: ?
jacobly
jacobly10mo ago
it's cart.framebuffer + 1 so 0x1e + 160 * 128 * 2 and it's the same number I came up with
widlarizer
widlarizer10mo ago
you can do that differently
mattnite
mattnite10mo ago
oof I tried to increase it for the frame buffer
JerwuQu
JerwuQu10mo ago
i think some of it is inherited from wasm4 and might not have gotten updated properly for u16 framebuffer etc
jacobly
jacobly10mo ago
you're good I just can't add hex numbers in my head
mattnite
mattnite10mo ago
okay sweet
jacobly
jacobly10mo ago
updated the sandbox to match
mattnite
mattnite10mo ago
yeah I used a python repl to do that
Corendos
Corendos10mo ago
Is there a way to get some timer info currently ? Like time since boot or something ?
jacobly
jacobly10mo ago
note that runtime_ram also acts as a stack protector, so lets not let it get tooo small currently stack size * 2, so should be good oh so after rebasing on main I see that the lcd is swapped looks more like the window than the madctl depends on if the garbage is random sram or random gram
mattnite
mattnite10mo ago
oh I found it or wait it's working correctly for me locally I swapped 128 and 160 in the LCD example
jacobly
jacobly10mo ago
also isn't window inclusive not exclusive I forget
mattnite
mattnite10mo ago
no idea
jacobly
jacobly10mo ago
I distictly remember always passing something like 0, 319, 0, 239 to other lcds
jacobly
jacobly10mo ago
No description
emidoots
emidoots10mo ago
there are a few badge bricks maybe at the mach table if someone can help out 🙂 cc @aurame
jacobly
jacobly10mo ago
you tried double clicking the button on the back?
emidoots
emidoots10mo ago
yeah
andrewrk
andrewrk10mo ago
I get a white screen when I flash my (working in the simulator) app to the badge
jacobly
jacobly10mo ago
that's expected
㎝
10mo ago
WSOD
Snektron
Snektron10mo ago
I got red now ish but its really slow
jacobly
jacobly10mo ago
hmm, the audio is not working as if the clock is wrong
mattnite
mattnite10mo ago
okay peeps it's 6am for me here I'm trying to hook up the DMA to the LCD by looking at jacob's stuff, it's the more-lcd branch if anyone wants to look at that good night, and thank you for all the help today
Snektron
Snektron10mo ago
thanks for your dedication matt 🙏
mholub
mholub10mo ago
interesting that Debug and ReleaseSmall builds work but ReleaseSafe gives strange error
install
└─ install generated to hello.uf2
└─ run elf2uf2 (hello.uf2)
└─ zig build-exe hello ReleaseSafe thumb-freestanding-eabi failure
error: error: <inline asm>:3:1: symbol 'initial_pause' is already defined
initial_pause:
install
└─ install generated to hello.uf2
└─ run elf2uf2 (hello.uf2)
└─ zig build-exe hello ReleaseSafe thumb-freestanding-eabi failure
error: error: <inline asm>:3:1: symbol 'initial_pause' is already defined
initial_pause:
andrewrk
andrewrk10mo ago
good night matt
jacobly
jacobly10mo ago
the clock seems to be off by 100x guess I need to measure all the clocks
Nailim
Nailim10mo ago
I think my badge died, plugged it in after a while, lit up for a couple of seconds and then nothing. No flashing. Any advice from the crowd?
mif
mif10mo ago
https://github.com/ZigEmbeddedGroup/sycl-badge/pull/49 works for me with this on the latest master 🤷‍♂️ could someone check this please? Not sure if the memory layout described in the PR will be the same for optimized/debug builds.
GitHub
simulator: neopixels memory layout fix by mifopen · Pull Request #4...
the actual neopixels layout is g r b g r b g r b g r b g r b, so I replaced Uint32Array with Uint8Array and adjusted u32 -> u8 u8 u8 parsing order
jacobly
jacobly10mo ago
Generator #2 (DFLL / 48): 1001368 Hz bzzzzt try again wait matt rearranged them all lol GCLK3 (8.467MHz) Generator #3 (DPLL1 / 1): 101792840 Hz not quite 100x beautiful Generator #3 (DPLL1 / 12): 8486904 Hz it's a note! it's a song!
JerwuQu
JerwuQu10mo ago
I like the sound of that!
jacobly
jacobly10mo ago
I can't make the timing sound good until the lcd is optimized, but pushing anyway
mif
mif10mo ago
I have somewhat corrupted lcd and no neopixels on master now. Is it a known issue?
jacobly
jacobly10mo ago
try now? neopixels were broken in release builds when you tried, and ignore lcd it is still all sorts of broken oh I see, neopixels are still broken in ReleaseFast only fixing now ok... how about... now?
mif
mif10mo ago
hmm, nope :/ tried with both ReleaseFast and Debug
jacobly
jacobly10mo ago
can I try the code you are running?
mif
mif10mo ago
ah, wait, I tried 0,0,0 for all leds 🤦‍♂️ all good, thanks!
jacobly
jacobly10mo ago
@Emil (widlarizer) if you still want to work on audio, the main todo is the non-square-wave channels
widlarizer
widlarizer10mo ago
hmm, so, DMA to DAC? what's the "State of the art" for buzzing rn
jacobly
jacobly10mo ago
quadbuzzing
widlarizer
widlarizer10mo ago
is that a branch
jacobly
jacobly10mo ago
it's on main now so yeah currently there's an interrupt every 12ms or so, that mixes from 12ms in the future to 24ms in the future and it fills one buffer while another buffer is dmaing to the dac
widlarizer
widlarizer10mo ago
how can I test it? This already uses DAC right
jacobly
jacobly10mo ago
cart.tone works, it's just that all channels are square waves and update isn't called consistently enough yet to do proper timing see also the song demo
widlarizer
widlarizer10mo ago
oh so DAC works?
jacobly
jacobly10mo ago
yeah just need to implement triangle and noise waveforms
andrewrk
andrewrk10mo ago
My badge app uses the LCD only
jacobly
jacobly10mo ago
to be clear, neopixels, sound, and buttons are the only things implemented and direct framebuffer access may work to some extent
widlarizer
widlarizer10mo ago
I don't get why "channel" means "wave function" 🤔
Bjorn
Bjorn10mo ago
I made a little planet destroyer game :P wanted to do more but ran out of time
Bjorn
Bjorn10mo ago
probably wouldn't work on the device
jacobly
jacobly10mo ago
one could imagine an api where you play an arbitrary waveform on each channel, but this api uses fixed function channels just like the gameboy audio hardware
andrewrk
andrewrk10mo ago
how come framebuffer doesn't have volatile
jacobly
jacobly10mo ago
probably because it used to not need to be volatile, and it didn't get updated correctly
andrewrk
andrewrk10mo ago
Direct framebuffer access works for me now!
aurame
aurameOP10mo ago
Looks like someone forgot their badge! I have it, please come get it if you lost it :)
㎝
10mo ago
sell it on ebay 🧌
aurame
aurameOP10mo ago
:wheeze: Thanks for attending y’all - hope you enjoyed hacking with the badges! :)
emidoots
emidoots10mo ago
Was very cool to see all the things people were building! I have a feeling I'm gonna see people continuing to hack on these lol - thanks for setting this up!
Bjorn
Bjorn10mo ago
It was a lot of fun thank you for setting it up!
aurame
aurameOP10mo ago
Thanks you Bjorn :) Huge props to Matt and Jacobly as well as everyone else who worked on the badge
mattnite
mattnite10mo ago
Thanks so much to @aurame and @JerwuQu | Marcus Ramse for putting together the emulator so people could make games without the badge working 100%
JerwuQu
JerwuQu10mo ago
@aurame is the real star!
aurame
aurameOP10mo ago
Aww you’re too kind, your help testing and fixing a bunch of bugs was invaluable
mattnite
mattnite10mo ago
Oh also I remember @slimsag mentioning bricked badges, did people try unplugging and plugging the battery back in? I forgot to document that Essentially something shorted the battery (maybe a zipper or smth) and the battery’s protection circuit latches to an off state until reset
krig
krig10mo ago
Starting to finally have something playableish running in the sim.. tried flashing it to the ROM. Screen is blank. :/ Will need to figure out how to debug tomorrow. Neopixels seem to work though..
Corendos
Corendos10mo ago
Did you try to build in debug mode ? Release seems to be broken rn
krig
krig10mo ago
haven’t tried that no! Will give that a go
pld
pld10mo ago
Had the same issue, traced it down to the cart.rect et al. procedures. They don't seem to work once running on the board. I replaced them with handrolled implementations to get it working again. Do the built-in ones are equivalent to a naive implementation like I had to write or do they use any hardware acceleration? (I haven't found anything in the SoC's datasheet that would be used for that, but I prefer to ask anyway)
Martin Fouilleul
Martin Fouilleul10mo ago
is writing directly to the framebuffer expected to be super slow?
mattnite
mattnite10mo ago
it shouldn't be slower than using the render functions that exist
Martin Fouilleul
Martin Fouilleul10mo ago
well maybe it's not actually writing to the framebuffer that is slow, writing only to part of it doesn't seem to change things too much. At what rate is the update function supposed to be called?
mattnite
mattnite10mo ago
For some information on frame rate issues: There's a lot more performance we can squeeze out of the hardware. Right now we're using the CPU to copy and send framebuffer bytes over SPI to the LCD. SPI is running at 4MHz but looking at the datasheet we could run it 16MHz maximum, I'll bump it to 12MHz to not tempt fate. That being said we're not fully utilizing the communication channel in this case, here you can see byte transfers with significant delays between them, instead of 1.5 Mbyte/s transfers, we're seeing 475Kbyte/s
mattnite
mattnite10mo ago
No description
mattnite
mattnite10mo ago
Full utilization at 12MHz is ~36 frames per second What we need to get this up is to use a DMA transfer instead of using the CPU
Iridescent Rose
Iridescent Rose10mo ago
I am still not getting it to work, my binary in Debug is ~430kb, I'm not sure if that's even fitting in the RAM
aurame
aurameOP10mo ago
Little surprise for y'all: the framebuffer has worked since this afternoon, but the draw functions (text, oval, rect, etc.) weren't implemented but here they are now: https://github.com/ZigEmbeddedGroup/sycl-badge/pull/53
GitHub
Implement draw functions by SuperAuguste · Pull Request #53 · ZigEm...
Blit Bounds checking for all draw functions
aurame
aurameOP10mo ago
not merging yet as i need to make sure the bounds checking is correct but if your programs use any of these functions and didn't work on the badge before, pull this branch in and try again :)
Iridescent Rose
Iridescent Rose10mo ago
Okay -- Release Small without drawing is ~56kb and runs but with rendering is ~59kb and hard crashes As in, complete refusal to load, just breaks
aurame
aurameOP10mo ago
hmm that's weird, im able to upload marler's blobs.uf2 to the badge (94kb) it does only show the menu before crashing if you press A to start the game though 😅 (so maybe this is actually a confirmation of your problem)
Iridescent Rose
Iridescent Rose10mo ago
Even on the working one the framebuffer partially has some garbage on the screen
Iridescent Rose
Iridescent Rose10mo ago
No description
Iridescent Rose
Iridescent Rose10mo ago
Hard crash on copying fw
No description
Iridescent Rose
Iridescent Rose10mo ago
Oh holy crap it's just that slow Nevermind I just needed to wait 5 minutes XD It is interesting that the neopixels didn't update until the end of the frame?
aurame
aurameOP10mo ago
it actually makes sense; the code updating the badge's state incl. neopixels runs after your program's update function (https://github.com/ZigEmbeddedGroup/sycl-badge/blob/f99f87c8ef90e13aa6749327986d1e221190d62c/src/badge.zig#L284-L289)
Iridescent Rose
Iridescent Rose10mo ago
Ah... I kinda want the neopixels to update and show scanline progress I suppose my demo now no longer needs "seconds per frame" but rather "minutes per frame"
Snektron
Snektron10mo ago
3d engine in progess... I can rotate a cube
Iridescent Rose
Iridescent Rose10mo ago
I had to reduce ray reflections from 8 -> 6 and samples from 15 -> 10 and it still is rendering
aurame
aurameOP10mo ago
ray reflections :wheeze:
Iridescent Rose
Iridescent Rose10mo ago
First raytraced frame
No description
Iridescent Rose
Iridescent Rose10mo ago
That actually took 10 minutes
krig
krig10mo ago
heck yes. It’s working. Way slower than the simulator so will need to tweak timings, but it definitely works.
No description
Snektron
Snektron10mo ago
t. Sleep deprivation
Iridescent Rose
Iridescent Rose10mo ago
I'm cranking the render settings up for prettier images 10 -> 25 samples 6 -> 7 max ray reflections Ready for it to take 30 minutes
captainhorst
captainhorst10mo ago
A Metal Gear-themed kitchen timer. ❗️ Not recommended for the use on planes though. 😅
Snektron
Snektron10mo ago
Martin Fouilleul
Martin Fouilleul10mo ago
with latests fixes i get « reached a code section marked unreachable » in the simulator (and nothing happens on the badge)
captainhorst
captainhorst10mo ago
Plasma + wavy text 🙂
gwenzek
gwenzek10mo ago
Pretty cool stuff. I'm struggling with RAM usage. I've crammed an ML model on the chip but using it for inference seems to copy too much of it into RAM. Any tips ?
Martin Fouilleul
Martin Fouilleul10mo ago
actually false alert, it does work now (i didn’t change anything… 🤷‍♂️)
Snektron
Snektron10mo ago
Quantization
gwenzek
gwenzek10mo ago
The model is already 2-bit quantized, and I do quantized matmul. But for some reason it uses more RAM I would assume. As if the full model was copyed into RAM, vs reading bytes one by one
jacobly
jacobly10mo ago
if you want to share your code with me I can see what is using ram
gwenzek
gwenzek10mo ago
GitHub
Mnist by gwenzek · Pull Request #1 · gwenzek/sycl-badge
error: ld.lld: section '.data.cart' will not fit in region 'cart_ram': overflowed by 90296 bytes error: ld.lld: section '.bss.cart' will not fit in region 'cart_ram'...
gwenzek
gwenzek10mo ago
thanks, I added some details and only kept the addBias that should only read a small slice of memory. building in release mode seems to solve the issue. So probably the debug mode doing to aggressive copies crap still 11126 bytes short
widlarizer
widlarizer10mo ago
I forgot to say, i think I have triangle waves working. But the internet is terrible everywhere so I didn't even push it yet
andrewrk
andrewrk10mo ago
That happened to me when I had an integer overflow or other kind of bug
widlarizer
widlarizer10mo ago
me too!
mholub
mholub10mo ago
I did compile simulator in debug and catched quite a few places where I had integer underflow
widlarizer
widlarizer10mo ago
It runs with default optimization level but not when I tweak the level did you need debug prints to find out where the problem is?
mholub
mholub10mo ago
Debug console in chrome did show panics with stack traces Wasm traces but better than nothing
mholub
mholub10mo ago
Definitely learning point for me is to have everything in i32/f32 for now and not try to optimize stuff. I might regret this decision a little bit later but it’s much easier to write math this way and not have these overflows
widlarizer
widlarizer10mo ago
I just don't know how to read a trace like this
RuntimeError: unreachable executed
bluescreenOnError runtime.ts:151
update runtime.ts:230
onFrame app.ts:368
onFrame app.ts:345
onFrame app.ts:345
onFrame app.ts:345
onFrame app.ts:345
init app.ts:385
$8bfb7e1400e402c9$export$86fbec116b87613f app.ts:97
da64fc29f17f9d0e custom-element.ts:21
da64fc29f17f9d0e custom-element.ts:64
$b3e975389288e776$export$29e00dfd3077644b tslib.es6.js:58
<anonymous> app.ts:16
RuntimeError: unreachable executed
bluescreenOnError runtime.ts:151
update runtime.ts:230
onFrame app.ts:368
onFrame app.ts:345
onFrame app.ts:345
onFrame app.ts:345
onFrame app.ts:345
init app.ts:385
$8bfb7e1400e402c9$export$86fbec116b87613f app.ts:97
da64fc29f17f9d0e custom-element.ts:21
da64fc29f17f9d0e custom-element.ts:64
$b3e975389288e776$export$29e00dfd3077644b tslib.es6.js:58
<anonymous> app.ts:16
mholub
mholub10mo ago
Mine were containing zig function names but I don’t remember how they looked. I can take a look in the break. I did nothing special. Could be specific to browser? I am using chrome
mholub
mholub10mo ago
yeah, so it's readable for me... at least which function contains the issue
fn make_undefined_behaviour() void {
gen = gen - 2; // unsigned underflow
}

export fn start() void {
make_undefined_behaviour();
if (scene == .intro) {
init_intro();
} else {
init_game();
}
}
fn make_undefined_behaviour() void {
gen = gen - 2; // unsigned underflow
}

export fn start() void {
make_undefined_behaviour();
if (scene == .intro) {
init_intro();
} else {
init_game();
}
}
No description
mholub
mholub10mo ago
wasm is not that readable 🙂 but it gives me rough understanding if UB is there and where to look
No description
widlarizer
widlarizer10mo ago
widlarizer
widlarizer10mo ago
Build with zig build watch-fireworks -Doptimize=ReleaseSmall or zig build -Doptimize=ReleaseSmall would be cool if you see more in Chrome :stare: I don't wanna download chrome over my phone connection
gwenzek
gwenzek10mo ago
error: ld.lld: section '.data.cart' will not fit in region 'cart_ram': overflowed by 1500003 bytes
error: ld.lld: section '.data.cart' will not fit in region 'cart_flash': overflowed by 1145093 bytes
error: ld.lld: section '.data.cart' will not fit in region 'cart_ram': overflowed by 1500003 bytes
error: ld.lld: section '.data.cart' will not fit in region 'cart_flash': overflowed by 1145093 bytes
Why is lld trying to copy .data.cart both to cart_ram and cart_flash ? I'd like to have data only in cart_flash
widlarizer
widlarizer10mo ago
blobs.zig has this. I am stealing it to see what's wrong
fn log(comptime fmt: []const u8, args: anytype) void {
var buf: [300]u8 = undefined;
const str = std.fmt.bufPrint(&buf, fmt, args) catch @panic("codebug");
cart.trace(str);
}

pub fn panic(
msg: []const u8,
trace: ?*std.builtin.StackTrace,
ret_addr: ?usize,
) noreturn {
log("panic: {s}", .{msg});
if (trace) |t| {
cart.trace("dumping error trace...");
_ = t;
//std.debug.dumpStackTrace(t.*);
} else {
cart.trace("no error trace");
}
cart.trace("dumping current stack...");
_ = ret_addr;
//std.debug.dumpCurrentStackTrace(ret_addr);
cart.trace("breakpoint");
while (true) { @breakpoint(); }
}
fn log(comptime fmt: []const u8, args: anytype) void {
var buf: [300]u8 = undefined;
const str = std.fmt.bufPrint(&buf, fmt, args) catch @panic("codebug");
cart.trace(str);
}

pub fn panic(
msg: []const u8,
trace: ?*std.builtin.StackTrace,
ret_addr: ?usize,
) noreturn {
log("panic: {s}", .{msg});
if (trace) |t| {
cart.trace("dumping error trace...");
_ = t;
//std.debug.dumpStackTrace(t.*);
} else {
cart.trace("no error trace");
}
cart.trace("dumping current stack...");
_ = ret_addr;
//std.debug.dumpCurrentStackTrace(ret_addr);
cart.trace("breakpoint");
while (true) { @breakpoint(); }
}
though I don't get a std.builtin.StackTrace
gwenzek
gwenzek10mo ago
I think I got it. Zig is putting my model in .data instead of .rodata and the linker script copies the .data to the cart_ram which make sense. Maybe I'm hit by https://github.com/ziglang/zig/issues/18404 ?
GitHub
Constant array data placed .data section instead of .rodata section...
Zig Version 0.12.0-dev.1856+94c63f31f Steps to Reproduce and Observed Behavior const std = @import("std"); const array1 = []u8{ 1, 2, 3, 4 }; const array2 = []u8{ 5, 6, 7, 8 }; const sl...
widlarizer
widlarizer10mo ago
Can't figure my problems out without the backtrace
jacobly
jacobly10mo ago
diff --git a/docs/introduction/src/hello.zig b/docs/introduction/src/hello.zig
index 9a65d07..460c3bc 100644
--- a/docs/introduction/src/hello.zig
+++ b/docs/introduction/src/hello.zig
@@ -27,8 +27,8 @@ export fn update() void {
}

const Img = [28][28]u8;
-const MNIST_DATA = @embedFile("t10k-images.idx3-ubyte.small");
-const MNIST_WEIGHT: []const u8 align(64) = @embedFile("mnist.q2.bin");
+const MNIST_DATA = @embedFile("t10k-images.idx3-ubyte.small").*;
+const MNIST_WEIGHT align(64) = @embedFile("mnist.q2.bin").*;

const n_images = @divExact(MNIST_DATA.len - 16, @sizeOf(Img));

diff --git a/docs/introduction/src/quant.zig b/docs/introduction/src/quant.zig
index a71ac13..f281677 100644
--- a/docs/introduction/src/quant.zig
+++ b/docs/introduction/src/quant.zig
@@ -1,8 +1,8 @@
const std = @import("std");

-const MNIST_WEIGHT = @embedFile("mnist-ggml-model-f32.gguf");
+const MNIST_WEIGHT = @embedFile("mnist-ggml-model-f32.gguf").*;
pub fn main() !void {
- const model: Mnist = Mnist.load(MNIST_WEIGHT);
+ const model: Mnist = Mnist.load(&MNIST_WEIGHT);
const fs = try std.fs.cwd().createFile("mnist.q2.bin", .{});
defer fs.close();

diff --git a/docs/introduction/src/hello.zig b/docs/introduction/src/hello.zig
index 9a65d07..460c3bc 100644
--- a/docs/introduction/src/hello.zig
+++ b/docs/introduction/src/hello.zig
@@ -27,8 +27,8 @@ export fn update() void {
}

const Img = [28][28]u8;
-const MNIST_DATA = @embedFile("t10k-images.idx3-ubyte.small");
-const MNIST_WEIGHT: []const u8 align(64) = @embedFile("mnist.q2.bin");
+const MNIST_DATA = @embedFile("t10k-images.idx3-ubyte.small").*;
+const MNIST_WEIGHT align(64) = @embedFile("mnist.q2.bin").*;

const n_images = @divExact(MNIST_DATA.len - 16, @sizeOf(Img));

diff --git a/docs/introduction/src/quant.zig b/docs/introduction/src/quant.zig
index a71ac13..f281677 100644
--- a/docs/introduction/src/quant.zig
+++ b/docs/introduction/src/quant.zig
@@ -1,8 +1,8 @@
const std = @import("std");

-const MNIST_WEIGHT = @embedFile("mnist-ggml-model-f32.gguf");
+const MNIST_WEIGHT = @embedFile("mnist-ggml-model-f32.gguf").*;
pub fn main() !void {
- const model: Mnist = Mnist.load(MNIST_WEIGHT);
+ const model: Mnist = Mnist.load(&MNIST_WEIGHT);
const fs = try std.fs.cwd().createFile("mnist.q2.bin", .{});
defer fs.close();

note that before it was aligning a slice, not what the slice pointed to, which is probably not what you meant anyway repro?
gwenzek
gwenzek10mo ago
Thanks. I find that a bit suprosong behavior from Zig. I would have assume embedFile meant .rodata
jacobly
jacobly10mo ago
it's a bug with unnamed constants, this workarounds that by naming them
widlarizer
widlarizer10mo ago
Guys I wanna go to a cafe that has functional wifi and sockets to hack on my badhe Who's in?
jacobly
jacobly10mo ago
@Emil (widlarizer) well first rand_mod crashes because int cast asserts that value doesn't change, it doesn't do any sort of truncation
widlarizer
widlarizer10mo ago
Yeah I've fixed some usage of that and will take a further look
jacobly
jacobly10mo ago
you can do global.rand.random().intRangeLessThanBiased(T, 0, max);
mholub
mholub10mo ago
Thanks. I didn’t know this thing exists
jacobly
jacobly10mo ago
or just uintRangeLessThanBiased(T, max) for unsigned next crash is @intCast(rand_mod(u8, 8) - 4); -4 doesn't fit in a u8 next crash is adding velocity, you probably want std.math.lossyCast instead of @intCast next crash is @aurame's fault
widlarizer
widlarizer10mo ago
Badge hacking group is going to be in the mall food court at the central circle thing while we wait for a nicer bigger table to become available!
aurame
aurameOP10mo ago
What did I mess up :(
jacobly
jacobly10mo ago
I think you didn't clip y in vline
aurame
aurameOP10mo ago
Oof sorry about that
widlarizer
widlarizer10mo ago
We have merged to a bigger table with the others
widlarizer
widlarizer10mo ago
mholub
mholub10mo ago
does anyone have problem that neopixels behave strangely? i.e. even with small values they are on full brightness all the time?
for (0..cart.neopixels.len) |i| {
const diff = @abs(@as(i32, @intCast(i)) - @as(i32, @intCast(pixel_pos)));
cart.neopixels[i] = switch (diff) {
0 => .{ .r = 50, .g = 50, .b = 0 },
1 => .{ .r = 40, .g = 40, .b = 0 },
2 => .{ .r = 30, .g = 30, .b = 0 },
3 => .{ .r = 20, .g = 20, .b = 0 },
else => .{ .r = 10, .g = 10, .b = 0 },
};
}
for (0..cart.neopixels.len) |i| {
const diff = @abs(@as(i32, @intCast(i)) - @as(i32, @intCast(pixel_pos)));
cart.neopixels[i] = switch (diff) {
0 => .{ .r = 50, .g = 50, .b = 0 },
1 => .{ .r = 40, .g = 40, .b = 0 },
2 => .{ .r = 30, .g = 30, .b = 0 },
3 => .{ .r = 20, .g = 20, .b = 0 },
else => .{ .r = 10, .g = 10, .b = 0 },
};
}
it feels it's binary - it is either 255 or 0
aurame
aurameOP10mo ago
Yeah they’re definitely not linear in terms of brightness lol
mholub
mholub10mo ago
but even 10, 10, 10 is full brightness for me I suspect 1, 1, 1 will be as well, so it's not really about linearity
aurame
aurameOP10mo ago
The brightness level definitely changes @Techatrix and I confirmed this yesterday
Techatrix
Techatrix10mo ago
Remember, Don't look at the badge while it is at 255! We learned that the hard way...
mholub
mholub10mo ago
yeah, same for me... I guess if I will be mugged in some dark street, I'll use the badge as defensive flashlight ok, feels like it's actually something like from 0 to 10 does change brightness
widlarizer
widlarizer10mo ago
I think we need gamma curve in the API implementation to get a good 0-1 step Huh the 8bit r g b values are directly written out to the neopixels That means we can do gamma correction just as well/poorly on the cart side.
widlarizer
widlarizer10mo ago
Adafruit Learning System
LED Tricks: Gamma Correction
RGB colors off? It’s not your LEDs or code…it’s biology!
widlarizer
widlarizer10mo ago
Great article We can't fix the 0-1 step seeming too big but we can fix the 1-2 step seeming too small
mholub
mholub10mo ago
I implemented this defensive mode and assigned dedicated button to it. Better to be safe
Snektron
Snektron10mo ago
DMA yet?
aurame
aurameOP10mo ago
Check out Jacob’s branch That makes use of dma
krig
krig10mo ago
I was having problems with my game getting more and more unstable and crashy.. then I left it plugged into USB for a while. Now it’s stable again. Must have been running out of battery 🪫
Snektron
Snektron10mo ago
Hell yes my badge is ready
JulienB
JulienB10mo ago
Thank you all for all the fixes and code samples. I finally managed to make my badge work
Martin Fouilleul
Martin Fouilleul10mo ago
so how does the dma work? do i just have to pull some branch?
Platy
Platy10mo ago
The "Jacob" branch presumably has DMA. I haven't tried it yet.
widlarizer
widlarizer10mo ago
I rebased my stuff onto jacob and got error: ld.lld: undefined symbol: start when I build for the hardware
pld
pld10mo ago
I tried out the branch yesterday, the framebuffer was displayed with top/left inversed (top was on left, left on top)
widlarizer
widlarizer10mo ago
it's for looking at yourself with your badge in a mirror
aurame
aurameOP10mo ago
You need to add an empty extern fn start to your code if you don’t have start logic
widlarizer
widlarizer10mo ago
I do have start logic
widlarizer
widlarizer10mo ago
aurame
aurameOP10mo ago
Huh that’s odd indeed
mlugg
mlugg10mo ago
glancing at badge/, am i right in saying the programmatically-accessible flash is unimpld so far the functions seem stubbed but i glanced at the linker script and there's runtime_flash and cart_flash memory regions which kinda implies there are two flashes memory-mapped but idk
jacobly
jacobly10mo ago
lol, so there's internal flash on the SoC and an external flash chip as part of the design, those memory regions are just partitions of the internal flash which is used for all read-only sections, such as code, read-only data, and writable data initialization nobody has written a driver for the external flash yet which is what the flash api is supposed to access
mlugg
mlugg10mo ago
okay yeah, makes sense could i theoretically throw data into the remaining internal flash space at cart_data_end?
jacobly
jacobly10mo ago
nobody has written a driver for that either
mlugg
mlugg10mo ago
i'm confused, why would i need a driver? isn't the whole point that it's memory-mapped, hence the cart_data_* symbols, e.g. used by fn start to load stuff
jacobly
jacobly10mo ago
flash cells are not physically written the same way ram cells are, so that only works for read/execute not write
mlugg
mlugg10mo ago
ah okay
jacobly
jacobly10mo ago
it's just a different interface than writing random access bytes note that both of the flash types support read/execute from memory addresses but the internal flash contains things like the initial stack pointer and instruction pointer, so that kind of has to be able to set itself up without any program code running the external flash is just connected to cpu pins that can be used for other purposes, so the cpu has no way of knowing if there is flash or not without some code to set it up
mlugg
mlugg10mo ago
okay i guess my game of life save/restore functionality will have to wait for another day
jacobly
jacobly10mo ago
how much space do you need btw?
mlugg
mlugg10mo ago
ideally 40k but i could get away with 5k by bitpacking if needed
jacobly
jacobly10mo ago
ok that's too much for the easy solution
JerwuQu
JerwuQu10mo ago
Forget if i showed my name cart but here it is
Agni
Agni10mo ago
finally made some progress on my own badge thing! it's a recreation of the "stratagem hero" minigame from helldivers 2. basic features are working. now i gotta make it look nice, add more stratagems, fix timing issues (you're not supposed to have that much time), maybe even add the helldivers theme as a chiptune??
Snektron
Snektron10mo ago
Agni
Agni10mo ago
he can't run around and desert you at that framerate
Snektron
Snektron10mo ago
hmm, something is wrong with latest master... if i write red then i get blue
aurame
aurameOP10mo ago
DMA change DisplayColor requires a byteswap I believe Jacob didn’t modify the struct to reduce breakage at compile time
Platy
Platy10mo ago
Can somebody write a patch to fix? I think the showcase carts are broken too. The API is high level enough that we should be able to avoid breakages completely.
Snektron
Snektron10mo ago
Not only that I had to change several things
not_motiejus
not_motiejus10mo ago
Hi folks. Are there any examples with a working LCD? I tried everything that's buildable in main, but output is garbled for all of them.
Snektron
Snektron10mo ago
The x/y coords need to be swapped And if you don't write fast enough to the fb youll need to double buffer, otherwise the dma copies the entire display before youre finished
aurame
aurameOP10mo ago
Huh interesting This makes sense
Agni
Agni10mo ago
what's the best way to get accurate timing on the badge? i.e. being able to say "wait 1 second"
JerwuQu
JerwuQu10mo ago
Oh, the display is rotated now? Interesting
Snektron
Snektron10mo ago
Seems so
not_motiejus
not_motiejus10mo ago
This is the "metal gear clock" demo, all demos look similarly. 🙂
aurame
aurameOP10mo ago
You can checkout from before the DMA merge
Platy
Platy10mo ago
I don't know if that's set up. I'm working on my own fork with better organization of code and a bunch of cool features like an actual tick system.
not_motiejus
not_motiejus10mo ago
Yep, that was it, thanks!
jacobly
jacobly10mo ago
that's now how the dma currently works, it probably has something to do with me changing the refresh rate of the lcd yeah these display are always portrait (these days), if it's landscape it's rotated
Snektron
Snektron10mo ago
Is there a way to signal to the display that it should copy memory? Double buffering works fine for me, but seems suboptimal
jacobly
jacobly10mo ago
no, not one the dma doesn't start until update returns what, whoever created this PR it was not up to date
Snektron
Snektron10mo ago
Ah
mattnite
mattnite10mo ago
reverting nvm jacobs on the case
Snektron
Snektron10mo ago
Wait no It's fast Just update the rest of the api
jacobly
jacobly10mo ago
@Robin what's your thoughts on splitting update into update and render where update runs concurrently to lcd dma and render waits for dma to complete before getting called and doesn't start dma until it returns the upcoming merge will just have update that acts like the render I just described
Snektron
Snektron10mo ago
I think that's a good take It may be hard to split it up like that for other people though Is there a way to check if the dma is done? Maybe it's good to expose a syncDisplay() api to users
Platy
Platy10mo ago
Draw should also be vsynced to 20fps or something because you really only need to draw that fast.. There is a way to poll for DMA a function to write it should be easy.
JerwuQu
JerwuQu10mo ago
i disagree on that there's no benefit to going faster than 20fps
Platy
Platy10mo ago
You've gotta check though. Ive worked with a similar screen that only actually updated the LCD that fast.
Iridescent Rose
Iridescent Rose10mo ago
"The human eye can only see 20fps!"
Platy
Platy10mo ago
Looking up there's a pin on the driver that controls the frame rate. I don't know if the display module is using it thoigh Either way the device has a fixed clock speed of 130MHz. It's relatively fast for a micro but cycles are a resource like any other, especially when you effectively need to lock the entire screen while the DMA uploads it.
jacobly
jacobly10mo ago
the point is you can still put everything in render and get the same behavior as before could also do the graphx thing where we wait on the first draw call, but that still requires calling a function before accessing the framebuffer so seems better to just have the user call it once and save cycles
Snektron
Snektron10mo ago
Yes that works fine i think
Martin Fouilleul
Martin Fouilleul10mo ago
how do you clear the screen after the latest changes? I'm trying @memset(cart.framebuffer, cart.Pixel{ .bits = 0 }) but I get expected type '[128]api.Pixel', found 'api.Pixel' and can't figure out how to pass a single black pixel
Snektron
Snektron10mo ago
Is cart.framebuffer a double pointer now?
Martin Fouilleul
Martin Fouilleul10mo ago
it's a *volatile [screen_width][screen_height]Pixel
andrewrk
andrewrk10mo ago
Convert the dest ptr into a flat slice Perhaps framebuffer.ptr[0..w * h]
mlugg
mlugg10mo ago
It'd be more awkward than that, accessing ptr will give a [*][screen_height]Pixel. I think (&framebuffer.ptr[0]).ptr[0..screen_width*screen_height] might work but at that point I'd personally just ptrcast lol
not_motiejus
not_motiejus10mo ago
My kid really likes zeroman, even at a few fps. He is very interested in changing the game himself (after he plays first, of course). And we were looking for a microcontroller upgrade. Thanks to everyone who made it possible, it was just on time for me. 🙂
krig
krig10mo ago
Created a PR for the showcase, to add my space shooting game. 🚀 https://github.com/ZigEmbeddedGroup/sycl-badge/pull/72
GitHub
Add space-shooter game to showcase by krig · Pull Request #72 · Zig...
Apologies for the code quality, this was the first zig code I wrote in a long time and a lot has changed. 😄 🚀
kristoff
kristoff10mo ago
I've created a long lived channel for the badge that will survive the event channel purge alongside photos. Consider moving new discussion about the badge there.

Did you find this page helpful?