The GNU toolchain and ARM toolchain have different approaches for handling the program's linking and loading.
A program have several sections for code and data. Normally in ARM embedded system, before invoking a program's "main" function, code/data sections needs to be located at exact position of the memory as specified in the linking time.
An simple example explaining what is happening at the early phase of program running
- A program image is loaded in to DRAM, each sections in the image are in their loading address now. The ARM toolchain call it loading address, GNU toolchain call it LMA(loading memory address), I will call it LMA now on.
- The next step is to make each section in the image to be relocated to their execution address as specified in the linking time. ARM toolchain calls it execution address. GNU toolchain call it VMA(virtual memory address), I will call it VMA from now on.
ARM toolchain using Scatter-loading mechanism to get section from LMA to VMA. For details, see http://wikigu.blogspot.jp/2017/01/arm-scatter-file-explain.html
One thing needs to be noted here is that, each section in ARM toolchain generated AXF file(ELF format) has the same LMA and VMA. The actually LMA/VMA mapping information is in linker generated InRoot$$Section. When ARM library function "__main" function is called, the section are copied from LMA to VMA according to info in InRoot$$Section.
GNU toolchain does not have similar Scattering-loading mechanism as the ARM. The LMA and VMA specified in the linker file are actually put in the ELF's header information. The LMA information is actually in the ELF's programmer's p_paddr.
The startup code of the image is responsible for copying the section from the LMA to VMA. There is no library function call provided by toolchain to do that.
Below is a good example.
https://www.embedded.com/design/mcus-processors-and-socs/4026075/Building-Bare-Metal-ARM-Systems-with-GNU-Part-2
https://www.embedded.com/design/mcus-processors-and-socs/4026080/Building-Bare-Metal-ARM-Systems-with-GNU-Part-3
2018/02/10
2018/02/01
Handling of Data Section In Image
ARM Linker
RW section is compressed in image the decompressed at loading.
http://www.keil.com/support/man/docs/armlink/armlink_pge1362065930871.htm
RW data areas typically contain a large number of repeated values, such as zeros, that makes them suitable for compression.
RW data compression is enabled by default to minimize ROM size.
The linker compresses the data. This data is then decompressed on the target at run time.
RW section is compressed in image the decompressed at loading.
http://www.keil.com/support/man/docs/armlink/armlink_pge1362065930871.htm
RW data areas typically contain a large number of repeated values, such as zeros, that makes them suitable for compression.
RW data compression is enabled by default to minimize ROM size.
The linker compresses the data. This data is then decompressed on the target at run time.
2017/09/11
Principle of Partial Response Maximum Likelihood (PRML)
This simple example demonstrates the principles of ML detection:
Decisions are made based on a sequence of samples, instead of one current sample. For each sequence of samples a list of allowable sequences is generated. Each of the allowable sequences is compared with the received sequence and SSE (or any other distance function) is calculated.
The sequence having the minimum distance (maximum likelihood) is selected to be the
result of the detection.
What should be stressed here is that the Viterbi algorithm is only (although smart and ingenious) a practical realization of the Maximum Likelihood detection principle which opened the way for effective real-time data detection.
Reference
http://www.lintech.org/comp-per/09PRML.pdf
2017/09/08
Tricky Things in New Ubuntu PC Setup
Fcitx input method panel not showing
I have a problem that fcitx google-pinyin panel is not showing on Ubuntu, the criminal is package fcitx-ui-qimpanel, after removing fcitx-ui-qimpanel, problem solved.
DNS not working sometimes
sudo gedit /etc/NetworkManager/NetworkManager.conf
Comment out line as:
#dnsmasq deactivated
#dns=dnsmasq
I have a problem that fcitx google-pinyin panel is not showing on Ubuntu, the criminal is package fcitx-ui-qimpanel, after removing fcitx-ui-qimpanel, problem solved.
DNS not working sometimes
sudo gedit /etc/NetworkManager/NetworkManager.conf
Comment out line as:
#dnsmasq deactivated
#dns=dnsmasq
2017/09/04
Create Simple DLL loadable by MatLab
Creating DLL
Create a new project in visual studio community 2017File -> New -> Project
On New Project Dialog
Installed -> Visual C++ -> Windows Desktop -> Windows Desktop Wizard
On Wizard Dialog
Application type -> Dynamic Link Library (.dll)
Additional Info:
check "Empty Project"
uncheck "Precompiled Header"
Add Files to project
Project -> Add New Item -> .cpp/.h ... etc
Set x64 or Win32 Platform as Active Configuration
Solution Explorer -> right click project -> Properties -> Configuration Manager
Code
simple.c
#define EXPORT_FCNS
#include "helper.h"
#include "simple.h"
int sq(int x)
{
return (x*x);
}
simple.h#ifndef SIMPLEH_H
#define SIMPLEH_H
#include "helper.h"
#ifdef __cplusplus
extern "C" {
#endif
EXPORTED_FUNCTION int sq(int x);
#ifdef __cplusplus
}
#endif
#endif
helper.h#ifndef HELPER_H #define HELPER_H #ifdef _WIN32 #ifdef EXPORT_FCNS #define EXPORTED_FUNCTION __declspec(dllexport) #else #define EXPORTED_FUNCTION __declspec(dllimport) #endif #else #define EXPORTED_FUNCTION #endif #endif
Loading DLL on Matlab
Setup compiler
on command window
mex -setup
Script
loadlibrary('simple')
libfunctions simple
calllib('simple','sq', 3)
Reference
https://stackoverflow.com/questions/18413118/visual-studio-dll-and-matlab2017/08/13
2017/06/06
SSD Controller Architecture
https://www.cactus-tech.com/resources/blog/details/solid-state-drive-primer-8-controller-architecture-channels-and-banks
Subscribe to:
Posts (Atom)
Post Code on Blogger
Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...
-
Explain There is not interrupt PIN for PCIe interrupt. When device wants to raise an interrupt, an interrupt message is sent to host via ...
-
Configure Space Addressing One of the major improvements the PCI Local Bus had over other I/O architectures was its configuration mechanism...
-
Example goes here: String url3 = " https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=barack%20obama " ; JsonpR...
