Booting SnapGear embedded Linux

本文详细介绍了如何在LEON3嵌入式系统中安装Linux,包括下载工具链、安装SnapGear Linux 2.6版本、配置内核与应用程序、解决bug及构建最终镜像的过程。
部署运行你感兴趣的模型镜像
2012-02-10 Publicerad av Sven-Åke Andersson

Introduction


We are now ready to install Linux in our LEON3 embedded system. We will use a special version of SnapGear supporting LEON2 and LEON3 which can be downloaded from the Aeroflex Gaisler ftp site.

LEON Linux


There are two different versions of the Linux kernel in the Gaisler SnapGear distribution, namely 2.6.x and 2.0.x. The 2.0 version is modified for use with MMU-less LEON systems, it is called micro controller Linux –μCLinux.  Version 2.6.x has support for MMU systems only, the kernel is from kernel.org with LEON specific patches and additional drivers mainly for GRLIB hardware. We will use 2.6.21.1 a rather old version but good enough for our needs. For more information about SnapGear Linux read the Snapgear for LEON manual.


Download and install

 

We will goto the Linux download page.



 

Install the toolchain



We will download and install the LEON GLibC Cross-compiler (linux-x86 host) from the ftp site:

 


 
The installation process for the different toolchains is the same, it is only the names and paths that differ. All toolchains must be installed to /opt and the path to the toolchain binary directory (/opt/sparc-[uc]-linux-3.x.x/bin) added to the shell PATH variable. Here is the result after unpacking the package.


 


 

Installing SnapGear Linux 2.6



Download snapgear-2.6-p42.tar.bz2 from the Gaisler ftp site.

 




Install the SnapGear distribution anywhwere in your home directory by extracting it:

mkdir ~/SnapGear
cd ~/SnapGear
tar -xjf /path/to/dist/snapgear-2.6-p42.tar.bz2


 



 

Hardware support in Linux 2.6


Here is a list of GRLIB hardware blocks that are supported in Linux 2.6
  • MMU
  • LEON3 SMP
  • GRETH 10/100/1000 Ethernet networking support
  • SMC91x 10/100 Ethernet networking support
  • OpenCores 10/100 Ethernet networking support
  • PCI support (GRPCI)
  • GRETH over PCI
  • ATA DMA and non-DMA (ATACTRL)
  • Host USB 1.1 and/or 2.0 (GRUSBHC)
  • PS/2 support (GRPS2)
  • SVGA Framebuffer (GRVGA)
  • Text VGA support (APBVGA)
  • I2C support (I2CMST)
  • SPI support (SPICTRL)
  • APBUART and GRTIMER
     

Configuring Linux
 

SnapGear comes with an easy to use graphical interface similar to the Linux kernel's configuration utility. From the GUI it is possible to select processor, Linux version, C library and what applications will be included into the root file system (ROMFS image) accessed by Linux during runtime. It is also possible to configure the boot loader parameters and configure the Linux kernel. The GUI can be launched by doing <make xconfig>.

 



The main configuration menu will appear. We will leave most of the settings unchanged for the time being, but there are a few things we must configure.
 




 

Click the Kernel/Library/Default Selection buttton and select kernel version linux-2.6.21.1. The version 2.6.29 seems to have some build problems. Select the Yes button for <Customize Vendor/User Settings> and go to the < Main Menu> and <Save and Exit>.
 




Then this window will open. We have to include some applications to make the build process finish without errors. For now we will only include BusyBox. Click the BusyBox button.

 


 


Enable the BusyBox application and go to the Main Menu and save and exit.




 

Fixing a bug


The first time we run make we got the following error message:
 


 

After searching the Gaisler support page I came up the following solution. Adding the line:  #include <linux/limits.h> in the file: snapgear-2.6-p42/linux-2.6.21.1/scripts/mod/sumversion.c




 

Building SnapGear



After configuring the kernel and the applications it is possible to compile and build the SnapGear LEON Linux distribution using the command: make.




 


If the build is successfull, the images will be placed in the image sub-directory. There are two types of images.
 
  • image.flashbz : PROM image that will first decompress the the kernel and applications into RAM and run everything from there
  • image.dsu       : RAM image suitable for download and excution on target hardware using the DSU, or on the TSIM/GRSIM simulators
     

 



Download SnapGear image



We will use GRMON to download and run the image. Here is the command to start GRMON using the USB cable:

grmon-eval -xilusb -nb -u

Here is the command using the ethernet connection (goes much faster):

grmon-eval -eth -ip <ip_address> -nb -u



 


 
Load the image.




 

and run.



 
Hopefully our Linux image will boot.



 

 

您可能感兴趣的与本文相关的镜像

LobeChat

LobeChat

AI应用

LobeChat 是一个开源、高性能的聊天机器人框架。支持语音合成、多模态和可扩展插件系统。支持一键式免费部署私人ChatGPT/LLM 网络应用程序。

### IGMPv2 查询报文与报告报文的组地址处理 在 IGMPv2(Internet Group Management Protocol version 2)中,查询报文(Query Message)和成员报告报文(Membership Report Message)分别用于组播路由器探测本地网络中的组播组成员以及主机通知路由器其仍属于某个组播组。 查询报文的 `Type` 字段为 `0x11`,用于探测组播组成员。该报文格式如下: ```plaintext +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x11 | Max Response Time | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Group Address (仅在特定组查询时填充) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` - **Type**:固定为 `0x11`,表示这是一个组查询报文。 - **Max Response Time**:指定主机在响应报告报文前的最大延迟时间(单位为 1/10 秒)。 - **Checksum**:用于校验报文完整性。 - **Group Address**:若此字段为 0,表示这是通用组查询,用于探测本地网络中所有组播组的状态;若此字段为某个组播地址,表示这是特定组查询,用于确认某个特定组播组是否仍有成员存在。 成员报告报文的 `Type` 字段为 `0x12`,用于主机通知路由器它仍然是某个组播组的成员。该报文格式如下: ```plaintext +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 0x12 | Reserved | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Group Address | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` - **Type**:固定为 `0x12`,表示这是一个成员报告报文。 - **Reserved**:保留字段,通常设为 0。 - **Checksum**:校验字段,用于确保报文完整性。 - **Group Address**:必须填写,表示主机所加入的组播组地址。 报告报文在组成员加入组播组或响应查询报文时发送。该报文的目的 IP 地址为组播组地址,表示该主机仍属于该组播组,路由器应继续转发该组的数据。 ### 示例代码:解析 IGMP 报文类型与组地址 以下是一个用于解析 IGMPv2 报文类型的简单 C 语言示例: ```c #include <stdio.h> #include <stdint.h> typedef struct { uint8_t type; uint8_t max_resp_time; uint16_t checksum; uint32_t group_address; } igmpv2_header; void parse_igmpv2(const uint8_t *data) { igmpv2_header *hdr = (igmpv2_header *)data; if (hdr->type == 0x11) { if (hdr->group_address == 0) { printf("通用组查询报文\n"); } else { printf("特定组查询报文,组地址: %u.%u.%u.%u\n", (hdr->group_address >> 24) & 0xFF, (hdr->group_address >> 16) & 0xFF, (hdr->group_address >> 8) & 0xFF, hdr->group_address & 0xFF); } } else if (hdr->type == 0x12) { printf("成员报告报文,组地址: %u.%u.%u.%u\n", (hdr->group_address >> 24) & 0xFF, (hdr->group_address >> 16) & 0xFF, (hdr->group_address >> 8) & 0xFF, hdr->group_address & 0xFF); } else { printf("未知 IGMP 报文类型: 0x%02X\n", hdr->type); } } ``` 该函数接收 IGMP 报文的原始数据并解析其类型和组地址字段,输出相应的信息。 ###
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值