So hello everybody, welcome to this talk.
So the title is poke all the microcontrollers, but the story is GNU poke inside GDB.
So we'll talk about poke and GDB more than microcontrollers, so sorry for that part.
But let's go to the...
So first of all what's GNU poke?
So it's the extensible, you can read it here, so the extensible editor for binary, for structured
binary data, which is...
So what's binary data?
It's data encoded in sequence of bits, binary digits, 0, 1, and like this.
And we can...
So there are structures there.
So it means there are relationship between the different bits, okay, like here.
We like grouped in four bits, in labels.
And like we can assign meaning to a part of like this structure, like this eight bits
as a whole to be a number 67, for example, as a signed integer of bits eight.
Or we can assign a meaning like a character C as ASCII does.
So it's like this is the part of the structures.
And then you can have more complicated structures, like this part is the length and this is the
table everything, so it's something like that.
So and then the editor is that you have the CLI, which you can view the content and you
can change it, hence the name poke.
And it's immediate, so it's like interactive, it's not about like...
It's about when you are exploring the data, you're debugging, you're doing something, you're
designing a data structure, like for encoding data, that's the best thing.
You can use.
So and it's extensible.
So it means that there is a DSL to describe this relationship between the bits, okay?
So bits, we are talking about like we can address each bits.
So and then it's inside of the GNU poke, we have this architecture, which is like you
have a leap poke, which is the library which implements, which has these three major components,
which is the first one is the PKL or poke programming language incremental compiler, which is the
incremental parts means that you can add definition, declaration.
It's statically typed, so it's like add the stuff to the namespace.
You can redefine things.
So the PVM, so it's a compiled language which compiles to a PVM, which is a poke virtual
machine supported by GNU Jitter, written by Luca Sayu.
And so this is, and then all the magics and the bits are lying here, the IU space.
And so and then the other thing is the programming like you can, okay.
So I don't know what's going on.
No, please.
Okay.
I can go to here, ext3, I guess.
Okay, so it's very not easy to see what's, my God.
Okay, so you can write poke and this is a program, which is a command line interface.
So this is the poke part of the story.
So this thing here, and there is a poke D, which is a demon so you can send the poke
code through the Unix socket.
So you can make interfaces and stuff like that.
There is a new component, poke fumpt, which is go through the source code and then there
are some tokens.
You can put poke code there, so it's useful for when you're generating test cases and
stuff, you can write poke.
And the result is the text like you assemble an instruction in poke and then at the end
in the test result, it's a number.
It's a UN32 number in hex, which is you or other tools can work with, but you know it's
like easy to debug because when you're writing the test, you know it's like poke code is
freeable.
So and then also this is useful when you want to or working with hardware, you have a bunch
of registers.
You can design like which bits you want to set and then you generate a .config c file
included and you're done.
You don't need to be like a coding c function, GPIO, init, clock, that thing, something.
You can all put write in poke and then generate the numbers, the final numbers and just write
the number to the register.
So GNU poke in GDB.
WTF so I cannot say the word.
Because GDB is good at debugging.
We are not.
And if you want to be, it's not possible because like after like you become a good thing after
some years.
But GDB is good at debugging, but maybe not as good as Gnu Poke is at poking a binary
data.
So this will be a happy marriage, we hope.
So and the question is okay, what we have already Python integration in GDB.
So why we need a new other language and the answer is right, that's correct.
It's a general purpose language.
You can do whatever you want to do in that language because it's a general purpose language,
of course.
But there is a but here.
It's a general purpose language.
So it's not good because what we're talking about here, like you can be what, yeah?
Because the poke is a DSL, like with uppercase p is the name of the language.
So poke is a DSL specifically designed to describe and poke binary data.
That's the reason we think it's a good combination.
And so what's the talk all about?
So my initial plan was more ambitious and had a lot of things with like life hardware
thinking.
You know when hardware and things come.
So plan is a little bit, but I have hardware here.
I can, I'm not disconnected.
It's here, it's real.
So it's partially right, but not quite as like I wrote in the abstract.
I was too much ambitious.
So okay, so it's a demo for, it was my fault, not a limitation of, oh, really?
Okay, so it's a demo for showing integration of leap poke inside the GC, leap inside GDB
using this hardware, which is I showed you.
So let's see that hardware.
It's this hardware.
It's ESP32 C3 module, which is a risk five based microcontroller.
It's a 32 bit risk five thingy.
So other thing.
And so in this demo, you have to, so here if you can see that I connected these two
pins together to prevent the thing to go to the state.
So like it always boot up correctly.
So the LED, I copy pasted this thing from image.
I have the link in the end in there.
So, and then it's a risk five, so you can see it.
And then this is the flags for the compilers if you want to compile for this destination.
So, and so the idea is for the, like the thing is you want to do the board being.
So this is the idea.
This is the whole thingy.
So, so you'd like to the first step in board bring up is like check the hardware to see
things that should be connected, should be connected, and then things that should not
be connected should not be connected.
So this is the first seems obvious, but very important.
And then you connect it to the public supply with the current and see it doesn't like draw
too much.
And then the next part is this.
So it's classically you can go to the C compiler and then you write things and then gradually
add more stuff GPIO LEDs every laser, you know, add from a small thing.
And then you add more complicated things to that.
But here I'm what I'm proposing is like you have the GDB, you have the JTAC.
So it's a command line interface.
It's alive.
It feels like a shell and you have the superpower of poke.
Then you should be good with experimenting with different ICs.
Writing to registers and timers and stuff, right?
So why this hardware?
Because it provides the JTAC debugging over USB.
You don't need any external program.
That's great.
It's also cheap.
But we need, we have to compile the GDB, which this integration is not upstream.
But then the problem is I use this fork of GDB from Espresse, which is the vendor of this
chip, which is on this branch.
And you can find the, so, and then when you need the leap poke, which is both of those
things work, and you can find it here.
So the patch for the integration is old and not updated.
And yeah, here you can find it.
So I put back ported to the, this branch of the binutils and like ported to newer version
of poke too in order to be able to show something.
So let's poke together.
So we need to connect, use this open OCD to just create a GDB server.
So the next step is we run the GDB, which we compile with that thing.
Okay.
So nobody have questions.
I know.
So this is the GDB init.
So you have to limit the amount of hardware and things, blah, blah, blah.
And so this is the other part of the story.
I can, okay.
So the people who want to play with this thing, you can, there is this repo here.
It's not, so the official SDK is huge.
I hate it.
So this is a simple thingy, which in the three ESP, in that branch you have three files,
you have all the things you need.
You can play with that.
And then you have this, where is that thing?
You have this data sheet, which is awesome.
So have fun.
Okay.
So let's go to the next part.
So yeah, this is poke.
And you can see that we can describe numbers with weird width.
So this is an unsigned one with six bits.
This is, yeah, should be fast, but yeah.
So it's a programming language.
So, right?
It's a good one.
Yeah.
Yeah, yeah, yeah.
You should be careful when asking for things.
You know, everything is good.
All is good, as German said.
So here we can also have aliasing for types.
So you can have the things.
So you in seven, you in something.
You can have, okay, it's not important anymore.
Okay, so this is the open OCD part, which you can see that I already did that.
I hope it still work.
And then here we have this GDB thingy with all the hex, the foot.
I put things together so it's not clean.
I did not show you.
So and then I had something.
Yeah, so I have to write it here.
So it was risk five, risk 532LGDB.
You have to have that thingy, GDB in it.
So we are here, please work.
So it's reading, reading flash.
It's doing that.
So it's good, great.
And now the GDB, so it's complain, no, I don't know what you're going, I know what I'm doing.
So it's okay.
So because there is no file in anything, so you had no idea what's going on.
So you can see that layout next.
We have a jump and then we have a like weird stuff somewhere.
So we can go next instruction.
It's somewhere, okay?
So now poke.
You have this poke subcommand, something in the GDB.
So you can say, like you can ask that poke, what's the read the 132 bit unsigned integer
at offset, what's the address of that thing?
0x4123, 1e9c for example.
And is it correct?
I hope it's correct.
So you have to see the same number.
Okay.
I cannot verify that.
So you have to see the number.
Okay.
Oh, we can, we can, we can.
We can like this, verify that.
So it's a content of this.
There's my mouse.
Please work, doesn't work.
Why?
It's your fault, you know.
It's 1e9c.
So you should get the same not getting because of the Indianness.
You have to poke, set Indian to Indian big, I guess, or little or I don't know.
Okay.
Also think, okay, now things are not, still not.
So it was little.
Yeah.
So please work.
Finally things, good.
Then I'm happy about that.
So let's, so you can have everything.
You can define variables here.
You can print stuff here from printfv, something, please work, don't crash, works, and doesn't
crash.
So you see you have the old CLI capabilities in the poke here.
And then you can do, okay, we have, you saw this thing, it's a module.
So we call it people.
So we load this, it's part of the standard, so it's riskv.pk.
So we say pk load riskv and then five or, good.
Yeah, okay, okay.
So you load the module and then next, so it gives you a bunch of definitions.
So what I'm interested in is, in some, here.
So this is an instruction of this risk five.
Please work.
Okay.
So you have this many variants.
So either it's formatted in R format, ISP, whatever, whatever.
So we want to decode that integer.
We had here as an RV32, what was that, instant?
Or yeah, yeah, yeah.
Okay, layout, next, more next, TOI disabled, please.
Okay, okay.
Okay, great.
Thank you, Petru.
Okay, so now you have all the, this part, like immediate part and then this is like,
because it was, if you do remember, it was a, we can disassemble that also.
If we do this.
Okay, thank you.
Disassemble from here to, from here to what the hell.
So C80, let's go for, no, it should be.
No, no, nine, yeah.
A0, yeah.
Yeah, this, yeah.
So here, we had this thingy here.
So then, so it's, now it's a poke variable.
We can call methods on that.
And this is, please unmask, it's not the time to re-syntex.
Okay, so you see that, yeah, we are getting the same thing.
So this gives us by the disassembler.
This is the magic of poke.
So we have other, so you have, I don't know, here, yeah.
We have this, the ATAC sheet, so there are registers, you can configure things this way.
So questions, you're happy now?
Thank you.
For example, can you change the T0 on the flight to some other register or 260 so you
could patch it on the.
If the function is inside this, in the RAM, yeah, definitely you can do that.
I don't have the courage to do that now, but you have to trust me.
Yeah, more questions, please, because.
Yeah.
For microcontrollers, it's like a script language for registers.
Yeah.
It's this one, this one, this one.
So this is SVD, they, they, so you don't need to read all the, all the data sheet to understand.
So you can have libraries like this is, sorry, Jose Python library, which you can use this
description of all registers and you can like generate the syntax for poke and then you
can like load whatever types you want and then poke them.
So you can, yeah.
So if I use like not, yes please, 32, but something normal.
Yeah.
Is it already up to them in GDP?
No, no, I told it's not.
It is false, you know, you can blame him.
He don't care, you know.
So like on a serious note, the problem is that they didn't opera-seam is that the GC,
you're using the boom GC and also GDP uses the boom GC for the guile.
So there's a problem there.
So we have to overchange the GC, please, Luca, you know, you can ask him to give us
a new GC, then we can opera-seam.
So that's the real answer, sorry for joking.
Yeah.
So next one.
Yeah.
So, yeah.
So I told you nobody has any questions, you know.
Thank you.
Wow.