Although I like the codebug hardware i'm a bit of a stick in the mud when it comes to online/cloud ide's/programming so have done some cursory looks at how to program the codebug without needing the internet.
i've looked at the binary that is loaded on the codebug and so far not found anything i'd normally expect to see in a binary except a few signature bytes. and possibly a few length bytes and some other odds and sods.
i made 3 bare bones files to see if i could spot a starting point but changing a single bit (ok byte) causes many changes to the resultant binary, many more than i'd expect.
has anyone cracked the cbg file format or got any other discoveries that would allow us to dump blockly? it looks like the blockly is turned into "normal" java script and i see references to build.py when trawling thru the codebug javascript & css etc.
bst rgrds
uks
CBG file format
Re: CBG file format
Probably will happen eventually, the original kickstarter said:
Drag and drop blocks to create your program (or edit the Javascript if you're a pro)
Control via javascript, Python, C, nodeJS Libraries
Re: CBG file format
yup, in theory you can already do that if you tether it but i'd like to program it then wander around wearing it. i'll keep rolling along trying to work it out but it's not as easy as cracking some other file format/shrouding that i have before
uks
uks
Re: CBG file format
This is probably 'Sucking Eggs' territory, but I'll risk throwing it out in case it helps...
The processor on the CodeBug is a Microchip PIC 18F25K50. Datasheet: http://ww1.microchip.com/downloads/en/D ... 00684B.pdf
Is it possible that the .cbg file generated by the online Blocky/JS => download_format process is a file of PIC op codes, maybe in whatever 'wrapper' the PIC bootloader requires?
The processor on the CodeBug is a Microchip PIC 18F25K50. Datasheet: http://ww1.microchip.com/downloads/en/D ... 00684B.pdf
Is it possible that the .cbg file generated by the online Blocky/JS => download_format process is a file of PIC op codes, maybe in whatever 'wrapper' the PIC bootloader requires?
Re: CBG file format
I've had a look at the .cbg files and it looks like it is indeed a CodeBug-specific wrapper around PIC18 code.
From what I can tell, the files are separated into blocks, each with a "CBG\0" header, followed by the project number (from the CodeBug web site). Each block seem to contain 28 "lines" (possibly less if it's the last block), with each "line" starting with what seems to be a memory address (starting at 0x4000) followed by 16 bytes of PIC18 instructions.
If you extract the code from the lines, you end up with a PIC18 program, which seems to mostly contain library code (possibly also some data; some of the code sections make little sense). The user code goes somewhere in the middle, so a small Blockly code change can cause a lot of differences in the PIC18 code, as all the subroutine addresses change.
I hacked a quick disassembler, and the input code is fairly easy to recognise in the PIC18 code. For example, "io_configure_pullup(2, 0);" translates as:
Translating your own code into .cbg will probably be troublesome without having the source of all the setup/library code.
From what I can tell, the files are separated into blocks, each with a "CBG\0" header, followed by the project number (from the CodeBug web site). Each block seem to contain 28 "lines" (possibly less if it's the last block), with each "line" starting with what seems to be a memory address (starting at 0x4000) followed by 16 bytes of PIC18 instructions.
If you extract the code from the lines, you end up with a PIC18 program, which seems to mostly contain library code (possibly also some data; some of the code sections make little sense). The user code goes somewhere in the middle, so a small Blockly code change can cause a lot of differences in the PIC18 code, as all the subroutine addresses change.
I hacked a quick disassembler, and the input code is fairly easy to recognise in the PIC18 code. For example, "io_configure_pullup(2, 0);" translates as:
Code: Select all
44ba: 0e 00 00001110 00000000 movlw 0x0000 ; W=L
44bc: 6e 17 01101110 00010111 movwf 0x17, ACCESS ; F=W
44be: 0e 02 00001110 00000010 movlw 0x0002 ; W=L
44c0: ec 02 11101100 00000010 call 0x4604, 0 ; Call subroutine