From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E55DEB64D9 for ; Fri, 7 Jul 2023 12:06:49 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.96) (envelope-from ) id 1qHkE0-0005zJ-2N; Fri, 07 Jul 2023 08:06:12 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qHkDy-0005yw-17 for kernelnewbies@kernelnewbies.org; Fri, 07 Jul 2023 08:06:10 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 031AA3200893; Fri, 7 Jul 2023 08:05:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 07 Jul 2023 08:05:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1688731558; x=1688817958; bh=Sc koxTKAYLynaYABVhTPWNMb/AF/Lf0Z6K24oHv0KBU=; b=ARfIKnOpiMrZL0DOGO yehW87XXBzeD2S/5C7krzcr7/hrve4JrIaRWMg209TsG0z8xOH5X7GQaAzttAoEj wyrjZk1y+TzT95+bdDIOIpCS93SU8nmgFDbJz9vKyo/CigG6f5IGrLzhewX/gjDb bA3WzzrwL4v+07wwir9McsOUIIpZ0J9iansD8gYjxQk9mGrSl855v+fzhDtduzv4 e+u/LLI5KLlodBG7djakS7e5L6uGVTv43Svi5CvrxJ3WRdb+8qfdXs6DEahmKTLY Jhc1XrLMdZieBvLlArEUSAoiSDDiAV1FY6/HQrt+TJ0aV70LEdQ/KpwWdA048+c4 8Z4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1688731558; x=1688817958; bh=SckoxTKAYLyna YABVhTPWNMb/AF/Lf0Z6K24oHv0KBU=; b=INy8mDelTNQgTgRPfna1sylnS7HyR YP1MVs0kyfC5bId/n5pIIIyPuFuTPVhBAJWka/8eiQvm1ISTy0Nmpb2eL7MTIObk wDnqjhA6uAwWhO9BtEcD0ro6KZlm65z3fYGgPdAGz1Xf+i4Tk2IhkPl69Qn//XT2 es8P8+oX+a4hABPbWOPV+JYwZqhl/a4xyKaKbbEsCNtQASbw1tYdxCyjpXMVhmSn U3EU9QS8BhNe8hmTNhxOYKF6Rj8CX/GZGCbvSxiD7H0v7K+3LrXg86qIGSoHxcAJ oMzyUzzzG4XNvEhNh1uB5y4bKf770sEzaoWfaXEqwEpnTnN69ZwzFb1Zg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrvddugdegkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggujgesthdtre dttddtvdenucfhrhhomhepifhrvghgucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheq necuggftrfgrthhtvghrnhepteeggfehhedvffekfeejveegteekfefgfffgueeltdevud dtiefhhfduvddtudelnecuffhomhgrihhnpehorhdrihhnnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Feedback-ID: i787e41f1:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Jul 2023 08:05:55 -0400 (EDT) Date: Fri, 7 Jul 2023 14:04:20 +0200 From: Greg KH To: Ayush Singh Subject: Re: Getting help in writing tty driver Message-ID: <2023070747-unable-punk-c8a6@gregkh> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Fri, Jul 07, 2023 at 04:37:53PM +0530, Ayush Singh wrote: > Hello everyone, I am working on a Google Summer of Code 2023 project [1] > under BeagleBoard.or. In this project, I have to write a Linux driver that > exposes `dev/ttyMCU0` (or something else) which can be accessed as a Serial > tty by MCUmgr [2]. This then sends the data and gets the response from the > CC1352 processor in BeagelPlay [3], which runs Zephyr over HDLC UART (the > data for this tty port has a particular HDLC address). > > However, all the resources I could find seem to use deprecated or old APIs > (like `alloc_tty_driver` instead of `tty_alloc_driver`). After some trial > and error, I was able to transfer the data written to `ttyMCU0` to CC1352 > using `write` in `tty_operations`. However, I am stumped on how to send > data to tty from the driver so that the userspace application can read it > (like using `cat`). Supposedly it should be done using > `tty_insert_flip_char` but the signature for this function in the tutorials > and the one present at `tty_flip.h` is quite different and does not seem to > work for me. Also, there seems to be something about the Echo flag but not > sure what all that is. > > Finally, I am not sure I understand the relationship between tty port, tty > device, and tty driver either so it would be great if someone can guide me > to resources related to tty. I think a simple tty echo driver should allow > me to get the hang of what I am supposed to do. Try looking at the tty driver example in the book, "Linux Device Drivers, third edition". It's out of date, but the ideas a much the same in places for tty drivers. And then look at any of the hundreds of in-kernel tty drivers for examples of what to do. You might want to look at the "smaller" ones as you don't want to get bogged down with the uart-specific stuff. good luck! greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies