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
@aurame help the simulator does not work
Watcher not found.
on both firefox and chromiumI use an extension to disable CORS in Chrome. Not sure if this is the intended way. 😅
@JerwuQu | Marcus Ramse suggested a workaround:
and then refresh the web page
that is not the solution, sorry; bug in build logic
i have a PR open to fix it
Yes, the watcher only builds when files change. You have to do a
zig build
firstbtw 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
Fetch API cannot load http://localhost:2468/cart.wasm due to access control checks.
This was the error I was working aroundbtw I found badgesim.microzig.tech works on chrome but not safari
2MB flash separate from the microcontroller's flash
2.6M zig1.wasmhmmmmmmm..........
only the first 2MB matter 😛
MOVE FAST AND BRICK THINGS
Where the readme says "the badge is still being worked on" who is working on it? I wanna work in it :zigfix:
@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
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?
I'm just about to merge a codegen bugfix, once I'm done that I have some peripherals I could use some help with
i hope you're merging a bug fix not a bug
otherwise it sounds like we're going backwards somewhat
ty
Got it
:wheeze:
Well you're not running wasm on the board right :monkaS:
nobody is stopping you...
why not? wasm interpreter :)
YO if anyone is having trouble cloning the repo, I have it on a flash drive, come get it from me
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"
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
@Emil (widlarizer) could you work with @slimsag to get a sound system going?
yea the nix.shell is outdated
There's an example one that @jacobly made under the old demo setup
src/cart.zig
and its the tone()
functionright after this lightning talk
I'll check out the related code while I'm at it
awesome, thanks
is there an experiment branch
I'm currently working on
badge-lcd
but besides that, main
is the closest thing since we're flying by the seat of our pantsmatt trying to save the badge rn
yes
is src/lcd.zig or src/board/lcd.zig the good one
robin asking the real questions
how do I run things in
src/badge/demos/
:KRRemHmmm:
nvm it's in zig-out/firmware/badge.demo.audio.elf
and uf2so audio works on the board right now?
this one did nothing on my badge
i don't believe so?
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
I have a QOA implementation in zig
unfortunately you can't play pcm with the api
👀
would be cool! the cart api currently only has a tone, not real pcm
you can hack around it though if you'd like :P
excited to hear the badge buzzer speaker version of the hit single "brick your badge"
src/board/lcd.zig
audio demo doesn't work probably bc the timer is borked
gclk
probably the problem with the lcd too
we don't have a clock?
audio stopped working because I tried to clean up some of the clock logic
ah
I'll have the fix in a couple min
is src/audio.zig used in the sim?
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?
@Emil (widlarizer) @andrewrk https://github.com/ZigEmbeddedGroup/sycl-badge/pull/45
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 speakin src/cart.zig you do have
pub fn tick() void
it writes from FRAMEBUFFER to lcd.fbI'm going to do some quick cleanup so it's more obvious what's old and what's not
nice!
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 thereoh ok

lcd demo
ish
the color isnt right
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
I ported the old audio code except dma so far
I do synthesis as the buffer empties regardless of the main loop
oh sweet, nvm @Emil (widlarizer) , one thing I could use another pair of eyes on is why the button state isn't updating
the lcd branch doesn't contain the microzig update last I checked
you do synthesis in an interrupt handler?
yep
I've been rebasing, I'll push
aye. How can I repro?
For the neopixels demo, when you press A the colors should change
cause I moved the neopixels from
start
to update
and the buttons work fine
well lol you meant that:facepalm:
:dennis:
is this functional? on some branch?
I think it's on the
jacob
branchdoesn't seem to be judging by
git log --stat
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
the bootloader may have happened to leave the mux "correct"
@aurame the emulator sound support is wonky for me, got a sec? orr maybe not, I'm not sure lol
@Robin how do you run the demo you sent? On main, when I put it into src/badges/demos/robin.zig and do
I get
src/badge/demos/robin.zig:39:21: error: root struct of file 'board' has no member named 'lcd'
The LEDs don't work if you flash the board. Signal looks a bit "off"

They worked for me. Where did you even connect your logic analyzer?
Which demo is this?
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
can I take a look?
it's on
jacob
well my git add didn't go throughyou need to click on the page once
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
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
yeah, you need to interact to let the browser know you trust the website :)
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
is there some way to slow down the execution, something like sleep function? 🙂
or timer?
you can just not do anything for the next n calls to update
The real solution is to implement a systick on a timer interrupt.
That just calls Tick++
not doing anything is ok for my case 🙂 thanks
once we get consistent timing for frames @mholub you'll be able to count ticks reliably for timing
Can't figure out how to build the audio code @jacobly ported
I basically got it to turn on, its white only
currently facing a linker script issue with the way I try to use it
Input pin of the first LED (neopixel/ws2812b)
It's the docs/introduction one, reduced to background fill and setting the LEDs
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
init builds now
can't really get it to draw a rectangle, this is my attempt:
nvm the hotreloading wasn't working right
Conversely can I overclock it?
The rays need to go faster 😛

ah that's probably just the backlight turning on
I have working rect drawing here: https://github.com/krig/sycl-badge/blob/krig/krig/src/main.zig
have you tried running it on hardware already?
idk if LCD is working / if the firmware works and doesn't brick
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?
I'm not really certain; I'm just following the instructions under the presumption they're right

wdym by init
This is correct
We're slowly making progress over here
I tried flashing, was able to get back to bootloader so I don't think it's hard-brickable (?)
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
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
Yeah that seems consistent with the instructions
This is expected
ported a demo, but dac not working yet
if you want a short circuit, you could only do square waves and just use the digital output
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@Emil (widlarizer) carts were supposed to be sandboxed but to save time and effort they've just become statically linked libraries
can I have microzig available in a cart?
alright I've now hit the unimplemented cart api lol
not having it helps people from shooting themselves in the foot, what reason do you need it?
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?
Yes that would be great!
I'm resurrecting the sandbox because the api depends on it lol
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
ok it's building already, I'm concerned
Is there a way to get debug output from the badge (that is not done by blinking the led)?
what does this mean?

my speaker just made the sound it makes when debugging an audio program
haha! interesting one
is there anything in the browser console?
the ear-deafening kind?
no just a swoosh
but it means it's close to working
you mean like blit vs blit16 ?
no the old one is a wasm4 compatible buffer
so 4bpp or whatever
nope
it's gone now 🤷♂️
:itisamystery:
does lcd work now?
can't find any remnants of that beyond an unused variable
:pausers:
dammit @marler8997 using all my ram
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
we could probably remove the startlogo?
I already gave in to your demands
the real issue was moving the framebuffer from runtime ram to cart ram
not yet it looks like
oh god it's buzzing
@marler8997 is pair programming with me rn on the LCD
oh wait that was the working audio demo, don't mind me
the audio demo is working now?
the non-demo audio demo
lol if I line step instead of instruction step it swooshes every time
it has audio?!
it sure is trying
that unlocked a new dimension for my project
yoo, I'm in a service call!
not sure how, everything before that is broken
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
that's MADCTL
no you're MAD
my badge just made an awful sound and then crashed
hell yeah
uhh, I think it's playing the sound... a bit too fast
like 15 seconds of music in under a second
does it mean lcd works if we pull or not yet?
does the rate limiter not work yet?
not yet
I'll fake it for now then
haven't fully tested the LCD out yet
Does
neopixels
actually work for anyone? I do
and it's one green (not red) light in simulator and ~rainbow on the actual badge.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
yeah the inline asm is broken in non-debug fixing now
Classic case
is it something I did or some compiler weirdness?
I failed to notice you did something bad
lmao
it's not even subtle
what was it?
you used labels
not allowed
-_-
how come?
how are you supposed to write assembly without labels?
badly
can someone test if
5dcca93c53d4d3e65b369847985896a24725deaa
fixes the problem?👀 which problem
release + neopixel
(I was at lunch)
ok
will test
it glows as expected
@aurame simulator needs updating for the
NeopixelColor
change
to fix this
and it's one green (not red) light in simulator
neopixels doesn't seem to react to A button :/
is that the bug that was supposed to be fixed?
on my commit it should work
this is at 5dcca93c
zig build +release
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
Yeah ik
Did y’all inverse it?
rotated more like
maybe main is fine
you mean the 0xA01E byte size of cart_fixed?
that's right
No clue where exactly it's coming from. Some kind of ahead of time reserved thing. @mattnite :stare: ?
it's
cart.framebuffer + 1
so 0x1e + 160 * 128 * 2
and it's the same number I came up withyou can do that differently
oof I tried to increase it for the frame buffer
i think some of it is inherited from wasm4 and might not have gotten updated properly for u16 framebuffer etc
you're good I just can't add hex numbers in my head
okay sweet
updated the sandbox to match
yeah I used a python repl to do that
Is there a way to get some timer info currently ? Like time since boot or something ?
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 gramoh I found it
or wait
it's working correctly for me locally
I swapped 128 and 160 in the LCD example
also isn't window inclusive not exclusive
I forget
no idea
I distictly remember always passing something like 0, 319, 0, 239 to other lcds

there are a few badge bricks maybe at the mach table if someone can help out 🙂 cc @aurame
you tried double clicking the button on the back?
yeah
I get a white screen when I flash my (working in the simulator) app to the badge
that's expected
WSOD
I got red now
ish
but its really slow
hmm, the audio is not working as if the clock is wrong
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 todaythanks for your dedication matt 🙏
interesting that Debug and ReleaseSmall builds work but ReleaseSafe gives strange error
good night matt
the clock seems to be off by 100x
guess I need to measure all the clocks
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?
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
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!I like the sound of that!
I can't make the timing sound good until the lcd is optimized, but pushing anyway
I have somewhat corrupted lcd and no neopixels on master now. Is it a known issue?
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?hmm, nope :/ tried with both ReleaseFast and Debug
can I try the code you are running?
ah, wait, I tried 0,0,0 for all leds 🤦♂️ all good, thanks!
@Emil (widlarizer) if you still want to work on audio, the main todo is the non-square-wave channels
hmm, so, DMA to DAC?
what's the "State of the art" for buzzing rn
quadbuzzing
is that a branch
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
how can I test it? This already uses DAC right
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 demooh so DAC works?
yeah just need to implement triangle and noise waveforms
My badge app uses the LCD only
to be clear, neopixels, sound, and buttons are the only things implemented
and direct framebuffer access may work to some extent
I don't get why "channel" means "wave function" 🤔
I made a little planet destroyer game :P
wanted to do more but ran out of time
probably wouldn't work on the device
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
how come framebuffer doesn't have
volatile
probably because it used to not need to be volatile, and it didn't get updated correctly
Direct framebuffer access works for me now!
Looks like someone forgot their badge!
I have it, please come get it if you lost it :)
sell it on ebay 🧌
:wheeze:
Thanks for attending y’all - hope you enjoyed hacking with the badges! :)
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!
It was a lot of fun thank you for setting it up!
Thanks you Bjorn :)
Huge props to Matt and Jacobly as well as everyone else who worked on the badge
Thanks so much to @aurame and @JerwuQu | Marcus Ramse for putting together the emulator so people could make games without the badge working 100%
@aurame is the real star!
Aww you’re too kind, your help testing and fixing a bunch of bugs was invaluable
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
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..
Did you try to build in debug mode ?
Release seems to be broken rn
haven’t tried that no! Will give that a go
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)
is writing directly to the framebuffer expected to be super slow?
dug up a bit, it's the same AFAICT, cf. https://github.com/ZigEmbeddedGroup/sycl-badge/blob/main/src/board/lcd.zig#L233 and https://github.com/ZigEmbeddedGroup/sycl-badge/blob/main/src/badge.zig#L250
it shouldn't be slower than using the render functions that exist
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?
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

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
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
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
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 :)
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
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)Even on the working one the framebuffer partially has some garbage on the screen

Hard crash on copying fw

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?
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)
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"
3d engine in progess...
I can rotate a cube
I had to reduce ray reflections from 8 -> 6 and samples from 15 -> 10 and it still is rendering
ray reflections :wheeze:
First raytraced frame

That actually took 10 minutes
heck yes. It’s working. Way slower than the simulator so will need to tweak timings, but it definitely works.

t. Sleep deprivation
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
A Metal Gear-themed kitchen timer. ❗️ Not recommended for the use on planes though. 😅
with latests fixes i get « reached a code section marked unreachable » in the simulator (and nothing happens on the badge)
Plasma + wavy text 🙂
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 ?
actually false alert, it does work now (i didn’t change anything… 🤷♂️)
Quantization
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
if you want to share your code with me I can see what is using ram
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'...
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 shortI forgot to say, i think I have triangle waves working. But the internet is terrible everywhere so I didn't even push it yet
That happened to me when I had an integer overflow or other kind of bug
me too!
I did compile simulator in debug and catched quite a few places where I had integer underflow
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?
Debug console in chrome did show panics with stack traces
Wasm traces but better than nothing
GitHub
[Draft] Signal generator functions: triangle and sine by widlarizer...
triangle sounds ok but idk how to check if truly correct. Sine is borked
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
I just don't know how to read a trace like this
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
yeah, so it's readable for me... at least which function contains the issue

wasm is not that readable 🙂 but it gives me rough understanding if UB is there and where to look

GitHub
GitHub - widlarizer/sycl-badge at fireworks-new
MicroZig running on the PyBadge! https://badgesim.microzig.tech/ - GitHub - widlarizer/sycl-badge at fireworks-new
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
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
blobs.zig has this. I am stealing it to see what's wrong
though I don't get a std.builtin.StackTrace
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...
Can't figure my problems out without the backtrace
note that before it was aligning a slice, not what the slice pointed to, which is probably not what you meant anyway
repro?
Thanks. I find that a bit suprosong behavior from Zig. I would have assume embedFile meant
.rodata
it's a bug with unnamed constants, this workarounds that by naming them
Guys I wanna go to a cafe that has functional wifi and sockets to hack on my badhe
Who's in?
@Emil (widlarizer) well first
rand_mod
crashes because int cast asserts that value doesn't change, it doesn't do any sort of truncationYeah I've fixed some usage of that and will take a further look
you can do
global.rand.random().intRangeLessThanBiased(T, 0, max);
Thanks. I didn’t know this thing exists
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 faultBadge 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!
What did I mess up :(
I think you didn't clip y in vline
Oof sorry about that
We have merged to a bigger table with the others
does anyone have problem that neopixels behave strangely?
i.e. even with small values they are on full brightness all the time?
it feels it's binary - it is either 255 or 0
Yeah they’re definitely not linear in terms of brightness lol
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
The brightness level definitely changes
@Techatrix and I confirmed this yesterday
Remember, Don't look at the badge while it is at 255!
We learned that the hard way...
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
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.
Adafruit Learning System
LED Tricks: Gamma Correction
RGB colors off? It’s not your LEDs or code…it’s biology!
Great article
We can't fix the 0-1 step seeming too big but we can fix the 1-2 step seeming too small
I implemented this defensive mode and assigned dedicated button to it. Better to be safe
DMA yet?
Check out Jacob’s branch
That makes use of dma
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 🪫
Hell yes my badge is ready
Thank you all for all the fixes and code samples. I finally managed to make my badge work
so how does the dma work? do i just have to pull some branch?
The "Jacob" branch presumably has DMA. I haven't tried it yet.
I rebased my stuff onto jacob and got
error: ld.lld: undefined symbol: start
when I build for the hardwareI tried out the branch yesterday, the framebuffer was displayed with top/left inversed (top was on left, left on top)
You need to add an empty extern fn start to your code if you don’t have start logic
I do have start logic
GitHub
GitHub - widlarizer/sycl-badge at fireworks-dma
MicroZig running on the PyBadge! https://badgesim.microzig.tech/ - GitHub - widlarizer/sycl-badge at fireworks-dma
Huh that’s odd indeed
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 idklol, 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
okay yeah, makes sense
could i theoretically throw data into the remaining internal flash space at
cart_data_end
?nobody has written a driver for that either
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 stuffflash cells are not physically written the same way ram cells are, so that only works for read/execute not write
ah okay
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
okay i guess my game of life save/restore functionality will have to wait for another day
how much space do you need btw?
ideally 40k but i could get away with 5k by bitpacking if needed
ok that's too much for the easy solution
Forget if i showed my name cart but here it is
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??
he can't run around and desert you at that framerate
hmm, something is wrong with latest master...
if i write
red
then i get blueDMA change
DisplayColor requires a byteswap
I believe Jacob didn’t modify the struct to reduce breakage at compile time
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.
Not only that
I had to change several things
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.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
Huh interesting
This makes sense
what's the best way to get accurate timing on the badge? i.e. being able to say "wait 1 second"
Oh, the display is rotated now?
Interesting
Seems so
This is the "metal gear clock" demo, all demos look similarly. 🙂
You can checkout from before the DMA merge
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.
Yep, that was it, thanks!
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
Is there a way to signal to the display that it should copy memory?
Double buffering works fine for me, but seems suboptimal
no, not one
the dma doesn't start until update returns
what, whoever created this PR it was not up to date
Ah
reverting
nvm jacobs on the case
Wait no
It's fast
Just update the rest of the api
@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 describedI 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
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.
i disagree on that there's no benefit to going faster than 20fps
You've gotta check though. Ive worked with a similar screen that only actually updated the LCD that fast.
"The human eye can only see 20fps!"
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.
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 cyclesYes that works fine i think
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 pixelIs cart.framebuffer a double pointer now?
it's a
*volatile [screen_width][screen_height]Pixel
Convert the dest ptr into a flat slice
Perhaps framebuffer.ptr[0..w * h]
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 lolMy 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. 🙂
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. 😄 🚀
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.