Im experimenting with RPi Pico and Rust. Im using rp2040-hal which has rom functions, including for writing to flash. For writing to flash you need to run the code from ram and not flash. To put the code in ram I think I need to use linker script. I have never written a linker script and I have no idea how would a linker script for copying code to ram looked like.
If the code gets too large you probably don't want to copy it to ram, only functions for writing to flash right? How can I do that?
Related
I have made a custom board for a TouchGFX application. I made an external loader, but the QSPI flash memory is not working properly.
Initially I did a test on QSPI flash and I could write and read data from it.
I can read and erase the Qspi with CubeProgrammer.
I modified the Linker script to add QSPI and specify memory region for ExtFlashSection, TextFlashSection, FontFlashSection in CubeIDE, but I get a hardfualt error.
Initialization
During the debugging I figured hard fault error happens when I get to "tick();" inside "virtual void backPorchExited()".
This error does not happen when I do not modify the linker script file for adding external qspi flash.
I am still codeing in the super loop mode and am not using Free RTOS yet.
Does anyone know what could be the issue?
I have the same problem. I was able to work around the problem by putting the font and the text in the internal memory. Since my project is done I'm back to try to solve this issue. Things that I have found out: reading out the external memory data matches the bin generated; therefore the problem has to be reading from the external flash during run time.
I am using my bluetooth module HC -05 to communicate through the UART1 of my microcontroller Atmega1284P. I have the memory mapped for both the boot loader and the application section. Now I am wanting to write a boot loader so that it receives hex files via bluetooth when received interrupt. How can I use Arduino IDE in writing a bootloader.? If possible, what are the functions to call the registers of MCU ? What are the function to write a page/erase a page in the specified memory ?
If it is not possible in arduino, what are the alternatives ?
Thanks in advance
Srinivasa Varadhan.
To break your question down into points: yes you can use Arduino IDE to program the bootloader, however it's not advised. For something like this you will need Atmel Studio since it has the registers built in for your micro to make things a LOT easier. Personally, I prefer CodeVision AVR to do it, there's a setting for bootloaders and lets you specify your micro.
Second off, if you pull up the datasheet for your micro (ATMega1284P) and look at section 26.8.13, you will see a perfectly good example of writing a page to memory. There is a whole section on writing the bootloader for that micro on the datasheet, so I would start there.
Also one last thing, yes bootloading sw over bluetooth is possible, but you'll want to make sure you're using proper flow control and checking the checksum of each line (again in the bootloader section). Also make sure that your bootloader memory area corresponds to that of what the micro is expecting. You can't really put the bootloader wherever you want and expect it to work.
I have the memory mapped for both the boot loader and the application section -- what does this mean? Specifically, how and where have you done this?
As far as I know you can't really use the Arduino IDE to write a bootloader. I mean, you can use it to enter your source code, but you can't actually use it to program the bootloader onto your microcontroller.
If you're using a standard Arduino board, it comes pre-programmed with the Arduino bootloader. The Arduino IDE can only program your microcontroller's flash memory by talking to this Arduino bootloader. The Arduino bootloader doesn't support replacing itself with a different bootloader, but even if it did your Arduino IDE would no longer be able to program anything on that microcontroller.
I have not used the Arduino IDE to do anything with bootloaders. My impression is that it does not give you enough control over memory mapping, linking, etc. It also makes development "easier" by compiling in its own main() loop -- this is fine for normal applications but absolutely not what you want for a bootloader.
What you want to do is get something like Atmel Studio, and a JTAG programmer like the JTAGICE mk2 or similar. Atmel Studio gives you control over every low-level aspect of your code, and the JTAG programmer will let you program the bootloader properly.
Explaning how to do flash programming from within your bootloader would be too much for this post. But see the datasheet here and the application note AVR109 here, they will give you some idea of what is involved.
I've written a program for a 3-bit multiplier in Vivado. I was trying to store that program in the SPI Flash memory of the device. The whole process of generating the .mcs file, choosing the configuration memory, uploading the .mcs file, uploading the bitstream file, etc. seems to work fine ( I get no erros ). But when I try to boot the device I get...
ERROR: [Labtools 27-2254] Booting from configuration memeory device
unsuccessful.
I heard there was a problem with Vivado 2014.1 and there is a particular work around but even that didn't work.
http://www.xilinx.com/support/answers/61067.html
Or the guide for the workaround.
http://forums.xilinx.com/t5/7-Series-FPGAs/Using-AR61067-for-SPIx4-Configuration/m-p/570312#M8339
So I am wondering is there something I'm missing, like a way to write my code - or important information with the TCL command to create the .mcs file?
Program Version: Vivado 2014.1
Device: Custom FPGA
I am a complete newbie to operating system and aiming to write my own kernel.
I understand that i will have to write my own device drivers as well.
How do i start with writing my driver?
The tasks of project are as follows.
1.Defining GDT in assembly language
2.Creating boot sector
3.Interrupt handling
4.Screen Driver
5.Keyboard driver
6.Hard disk driver
7.File system
8.I/O programming
9.Physical memory management
Also is it possible to do this in 3 months ( team of 2 )
As you know (or about to find out) OSes are extremely complicated and interconnected. For example, how are you going to have a working Keyboard driver before you have implemented interrupt handling?
It sounds like your question actually is: "How do I start writing my own OS?" You start by reading "Required Knowledge," "Beginner Mistakes," and "Getting Started" on osdev.
Good luck, and it is going to take a long time... especially if you are learning as you go (which is okay, since your goal is learning and not to make a commercial OS).
Edit: Modifying the Linux kernel is a good way to learn about the internals of an OS. It will let you focus on individual aspects (such as just writing a keyboard driver) and your work environment will be sane. Depending on what you want to do, you will be able to further ease development by creating a kernel module instead directly modifying the kernel.
Define your project and its scope
Set up your work environment (my suggestion, run Ubuntu Server in QEMU)
Learn how to either boot a custom kernel or use the module system
Get to work!
You can try looking into contributing to minix (http://www.minix3.org/)
There are a loads of things that are needed to be done .Have a look at (http://wiki.minix3.org/Wishlist).
I'm working an a system with embedded Linux (Kernel 2.6.31).
It is a AT91SAM9G20 chip inside, and some of the Pins are forwarded to the outside.
Now I want to use them as GPIO Inputs.
I read the gpio.txt documentation about using the GPIOs via filesystem, and that works very well 'til here. I connected some switches to the gpio-pins and I can see the result in /sys/class/gpio/gpioX/value. But now I'd like to react on a change without busy-waiting in a loop. (i.e echo "Switch1 was pressed").
I guess I need interrupts here, but I couldn't find out how to use them without writing my own kernel driver. I'm relatively new to Linux and C (I normally program in Java), so I'd like to handle the Interrupts via sysfs too. But my problem is, that there is no "edge"-file in my GPIO directory (I guess because this is only since Kernel version 2.6.33+). Is that right? Instead of "edge" I've got a uevent file in there, which is not described in gpio.txt.
In the gpio.txt documentation there was a Standard Kernel Driver mentioned: "gpio_keys". Is it possible to use this for my problem?
I guess it would be better to work with this driver than allowing a userspace program to manipulate kernel tasks.
I found a lot of codesnippets for writing my own driver, but I wasn't even able to find out which of the 600 gpio.h files to include, and how to refer to the library (cross compiler couldn't find the gpio.h file).
Sorry for newbie questions, I hope you could give me some advices.
Thanks in advance
See this for an example on how to do that. Basically, the thing you're missing is the usage of the select or poll system calls.