cinera_handmade.network/miotatsu/riscy/riscy/riscy022.hmml

80 lines
4.5 KiB
Plaintext

[video member=miotatsu stream_platform=twitch project=riscy title="Fun with Pointers & Printing" vod_platform=youtube id=ehPrF_R0EXY annotator=Miblo]
[0:19][Recap and set the stage for the day]
[0:45][Consult DrewatSiFive's reply to the forum post[ref
site="SiFive Forums"
page="Lots of Questions… (RISCY BUSINESS Day 21)"
url=https://forums.sifive.com/t/lots-of-questions-riscy-business-day-21/434]][:research]
[3:27][Pointer assignment[ref
site="SiFive Forums"
page="Lots of Questions… (RISCY BUSINESS Day 21)"
url=https://forums.sifive.com/t/lots-of-questions-riscy-business-day-21/434]][:research]
[8:46][The Privileged spec is up in the air[ref
site="SiFive Forums"
page="Lots of Questions… (RISCY BUSINESS Day 21)"
url=https://forums.sifive.com/t/lots-of-questions-riscy-business-day-21/434]]
[9:46][printf[ref
site="SiFive Forums"
page="Lots of Questions… (RISCY BUSINESS Day 21)"
url=https://forums.sifive.com/t/lots-of-questions-riscy-business-day-21/434]]
[12:20][:Run the hello world program to determine that we have a working printf()]
[13:17][@hossein1387][Yeah, it works for me too. Magic]
[13:33][Fix up the *config_string assignment in print_instructions()]
[16:45][Consult man 3 fflush and man 2 write][:research]
[18:43][Comment out the fflush(), make clean, compile and upload]
[19:33][:Run our demo_gpio.c program and view the output]
[20:38][Change the printf() to print a string]
[24:29][:Run and see no output]
[25:22][Compare the difference between printf() in gpio_demo.c and in hello.c][:research]
[26:46][Compare the Makefiles]
[27:26][@hossein1387][Can you try to clean your env? Because it works for me]
[27:50][Run make software_clean and remove the fflush()]
[28:45][:Run the program to see inconsistent writing]
[29:34][@hossein1387][I tried this in beginning of print_instructions(): unsigned char * ConfigString = (unsigned char*)*(volatile uint32_t *) 0x0000100C; printf("%s", ConfigString);]
[30:40][Consult man 3 printf]
[31:51][Make printf() print the address of config_string]
[32:37][:Run our program and view the output]
[34:51][Note how inconsistent the writing is]
[35:39][Consult man 3 printf again]
[37:53][Try casting config_string to void*]
[39:40][:Run our program and receive the same address]
[40:02][Set config_string without casting]
[40:50][:Run and receive the 0x100c address we were expecting]
[42:26][Set config_string with the cast again]
[44:00][:Run our program to see our output, with a few words on pointer dereferencing]
[45:20][Remember switching the jumper[ref
site="SiFive Forums"
page="Arch Linux and the HiFive1"
url=https://forums.sifive.com/t/arch-linux-and-the-hifive1/212]]
[47:46][:Run and view our output]
[48:02][Try to make print_instructions() write out the config_string using write()]
[48:41][:Run the program and view our correct config_string output, with a few words on where we got the config_string location]
[50:11][Try printing from 0x00020004]
[53:35][:Run the program to see nothing at that memory location]
[54:18][Consult the Pinout diagram in the Getting Started Guide[ref
site="SiFive Developers"
page="SiFive HiFive1 Getting Started Guide"
url=https://static.dev.sifive.com/dev-kits/hifive1/hifive1-getting-started-v1.0.2.pdf]][:research]
[57:51][Read about the HiFive1 Boot Sequence[ref
site="SiFive Developers"
page="SiFive HiFive1 Getting Started Guide"
url=https://static.dev.sifive.com/dev-kits/hifive1/hifive1-getting-started-v1.0.2.pdf]][:research]
[59:43][Read about OTP Contents[ref
site="SiFive Developers"
page="SiFive HiFive1 Getting Started Guide"
url=https://static.dev.sifive.com/dev-kits/hifive1/hifive1-getting-started-v1.0.2.pdf]][:research]
[1:02:29][Try to print the Board Identifier]
[1:05:35][:Run our program and see garbage output]
[1:06:02][Try to verify that 0x100C prints]
[1:07:44][:Run the program to see that it worked, and determine that the Board Identifier is not a string]
[1:09:41][Try to printf() the board_id as an unsigned int]
[1:12:20][:Run our program to see some output]
[1:13:16][Try to printf() the board_id as a char, cast to an int]
[1:14:20][:Run the program and hit a trap]
[1:15:06][@hossein1387][It's a trap!]
[1:15:11][Try to print the board_id as an int, cast to an int]
[1:15:45][:Run the program and hit a trap again]
[1:16:39][That's all that we have time for for today]
[1:16:53][@hossein1387][I tried to setup gdb for the board, but I got my OpenOCD all screwed up. I think gdb is very useful in these situations]
[1:18:41][Stay RISCY, everyone!]
[/video]