Globalmem for Linux device driver development

Source: Internet
Author: User

Two common errors:
1.When inserting a module, the following problems occur:

# Insmod globalmem. Ko insmod: Error inserting 'globalmem. ko':-1 device or resource busy

Answer:The master device number is in use.
You putGlobalmem. cThe macro definition in the file is changed226Or others, and then compile it to insert it!

Note:If the master device number is changed, you need to create the node next to it. Otherwise, the following error occurs:

# Mknod/dev/globalmem C254 0 /*Here254With the modified master device number228Inconsistent*/
# Echo 'Hello world'>/dev/globalmem
/Bin/sh: can't create/dev/globalmem: no such device or address

Solution:

# Rm/dev/globalmem
# Mknod/dev/globalmem C2260
# Echo 'Hello world'>/dev/globalmem
Written 12 bytes (s) from 0

2.The device node is successfully loaded and created.CatWhile reading the correct characters, the command always adds a prompt "the device or address cannot be found" at the end of the command. I do not know why this sentence will appear. 

# Echo 'Hello world! '>/Dev/globalmem
Written 13 bytes (s) from 0
# Cat/dev/
/Dev/console/dev/globalmem/dev/null
# Cat/dev/globalmem
Read 4096 bytes (s) from 0
Hello world!
Cat: read error: no such device or address
#
Answer: Actually, it's okay,
<1> You put Globalmem_read Function If (P> = Globalmem_size) Change If (P> globalmem_size) That's all. The specific cause is a call. Cat Read twice. 4096 Bytes. The file read pointer PPOs Yes 4096 In the second read If (P> = Globalmem_size) The condition here is true, Globalmem_read Returns Enxio The error is returned. No such device or address" Error. I don't know why it is correct on instructor Song's machine?
<2> Song Baohua
: The returned error value is correct. Because the read position has exceeded the limit, an error is returned. If the returned error is correct, the error is returned. Change If (P> globalmem_size) Yes.

<3> there is no error in the above two points. The output error message is normal debug information: CAT called Read twice.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.